Skip to content

Commit

Permalink
docs: ui.heading (deephaven#908)
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshatJawne authored Oct 2, 2024
1 parent 68b6515 commit 863655b
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
70 changes: 70 additions & 0 deletions plugins/ui/docs/components/heading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Heading

The Heading component is used to create different levels of headings.

By default, it creates a level 3 (`<h3>`) heading.

## Example

```python
from deephaven import ui

my_heading_basic = ui.heading("Hello world")
```

## UI recommendations

Consider using a [`text`](./text.md) component if the content does not require a specific heading level or semantic importance, such as for paragraphs or inline text.


## Content

The heading component represents a header that inherits styling from its parent container.

```python
from deephaven import ui


@ui.component
def ui_heading_content_examples():
return [
ui.heading("Heading 1", level=1),
ui.heading("Heading 2", level=2),
ui.heading("Heading 3", level=3),
ui.heading("Heading 4", level=4),
ui.heading("Heading 5", level=5),
ui.heading("Heading 6", level=6),
ui.time_field(
label="Sample Label",
contextual_help=ui.contextual_help(ui.heading("Content tips")),
),
]


my_heading_content_examples = ui_heading_content_examples()
```


## Color

The color prop sets the text color for the heading component.

```python
from deephaven import ui


my_heading_color_example = ui.flex(
ui.heading("Faded heading", color="gray-500"),
ui.heading("Negative heading", color="negative"),
ui.heading("Positive heading", color="positive"),
ui.heading("Hex color", color="#FA8072"),
ui.heading("Nested ", ui.text("example", color="green"), "!"),
direction="column",
)
```

## API Reference

```{eval-rst}
.. dhautofunction:: deephaven.ui.heading
```
4 changes: 4 additions & 0 deletions plugins/ui/docs/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
"label": "date_range_picker",
"path": "components/date_range_picker.md"
},
{
"label": "heading",
"path": "components/heading.md"
},
{
"label": "illustrated_message",
"path": "components/illustrated_message.md"
Expand Down
4 changes: 4 additions & 0 deletions plugins/ui/src/deephaven/ui/components/heading.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def heading(
UNSAFE_class_name: A CSS class to apply to the element.
UNSAFE_style: A CSS style to apply to the element.
key: A unique identifier used by React to render elements in a list.
Returns:
The rendered heading element.
"""
return component_element(
"Heading",
Expand Down

0 comments on commit 863655b

Please sign in to comment.