Skip to content

Commit

Permalink
docs: ui.text (#907)
Browse files Browse the repository at this point in the history
Closes #835

**Additional Info:**
- Link to markdown once implementation is finished

---------

Co-authored-by: margaretkennedy <[email protected]>
  • Loading branch information
AkshatJawne and margaretkennedy authored Oct 2, 2024
1 parent 356d33a commit 68b6515
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
77 changes: 77 additions & 0 deletions plugins/ui/docs/components/text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Text

Text represents text with no specific semantic meaning, serving as a basic element. It is equivalent to an HTML span element.

## Example

```python
from deephaven import ui

my_text_basic = ui.text("Hello world")
```

## UI Recommendations

Consider using [`ui.heading`](./heading.md) if you want to create different types of headings.


## Content

The text component is sometimes used within a parent container, like [`button`](./button.md) or [`picker`](./picker.md) to define text content when multiple children are passed (such as icons and descriptions). It inherits styling from its parent container.

```python
from deephaven import ui


@ui.component
def ui_text_content_examples():
return [
ui.button(ui.text("Press me"), variant="accent", style="fill"),
ui.picker(
ui.item(
ui.icon("github_alt"),
ui.text("Github"),
ui.text("Github Option", slot="description"),
text_value="Github",
),
ui.item(
ui.icon("azure_devops"),
ui.text("Azure"),
ui.text("Azure Option", slot="description"),
text_value="Azure",
),
),
]


my_text_content_examples = ui_text_content_examples()
```


## Color

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

```python
from deephaven import ui


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

## API Reference

```{eval-rst}
.. dhautofunction:: deephaven.ui.text
```




4 changes: 4 additions & 0 deletions plugins/ui/docs/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
"label": "Table",
"path": "components/table.md"
},
{
"label": "text",
"path": "components/text.md"
},
{
"label": "text_area",
"path": "components/text_area.md"
Expand Down
4 changes: 4 additions & 0 deletions plugins/ui/src/deephaven/ui/components/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ def text(
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 text element.
"""
return component_element(
"Text",
Expand Down

0 comments on commit 68b6515

Please sign in to comment.