@@ -4,129 +4,72 @@ Makes icons accessible by adding a label.
44
55## Features
66
7- - Quickly make any icon accessible by wrapping it and providing a meaningful label.
8- - No visual difference, but announced correctly by screen readers.
7+ - Quickly make any icon accessible by wrapping it and providing a meaningful label.
8+ - No visual difference, but announced correctly by screen readers.
99
1010## Installation
1111
12+ Install the component from your command line.
13+
1214{{#tabs global="framework" }}
1315{{#tab name="Leptos" }}
1416
1517``` shell
1618cargo add radix-leptos-accessible-icon
1719```
1820
19- - [ View on crates.io] ( https://crates.io/crates/radix-leptos-accessible-icon )
20- - [ View on docs.rs] ( https://docs.rs/radix-leptos-accessible-icon/latest/radix_leptos_accessible_icon/ )
21- - [ View source] ( https://github.com/RustForWeb/radix/tree/main/packages/primitives/leptos/accessible-icon )
22-
23- {{#endtab }}
24- {{#tab name="Yew" }}
25-
26- ``` shell
27- # TODO: Implement an official Yew crate for accessible icons if missing
28- # cargo add radix-yew-accessible-icon (when available)
29- ```
30-
31- - TODO: Provide crates.io, docs.rs, and source links when available.
21+ - [ View on crates.io] ( https://crates.io/crates/radix-leptos-accessible-icon )
22+ - [ View on docs.rs] ( https://docs.rs/radix-leptos-accessible-icon/latest/radix_leptos_accessible_icon/ )
23+ - [ View source] ( https://github.com/RustForWeb/radix/tree/main/packages/primitives/leptos/accessible-icon )
3224
3325{{#endtab }}
3426{{#endtabs }}
3527
3628## Anatomy
3729
30+ Import the component.
31+
3832{{#tabs global="framework" }}
3933{{#tab name="Leptos" }}
4034
4135``` rust,ignore
4236use leptos::*;
43- use radix_leptos_accessible_icon::primitive as AccessibleIcon ;
37+ use radix_leptos_accessible_icon::* ;
4438
4539#[component]
4640fn Anatomy() -> impl IntoView {
4741 view! {
48- <AccessibleIcon::Root label="Close">
49- // Your icon element here (e.g., <svg>)
50- // aria-hidden="true", focusable="false" are applied automatically
51- <svg viewBox="0 0 24 24">
52- // path definitions...
53- </svg>
54- </AccessibleIcon::Root>
42+ <AccessibleIcon />
5543 }
5644}
5745```
5846
59- {{#endtab }}
60- {{#tab name="Yew" }}
61-
62- ``` rust,ignore
63- // TODO: Provide a Yew example when the crate is available or supported
64- use yew::prelude::*;
65-
66- // Possibly something like this in the future:
67- // use radix_yew_accessible_icon::primitive as AccessibleIcon;
68- ```
69-
7047{{#endtab }}
7148{{#endtabs }}
7249
7350## API Reference
7451
7552### Root
7653
77- Contains the icon you want to make accessible.
54+ Contains the icon to make accessible.
7855
7956{{#tabs global="framework" }}
8057{{#tab name="Leptos" }}
8158
82- | Prop | Type | Default | Description |
83- | ------------| ------------------------------------------| ---------| ---------------------------------------------------------------------------------------------------------------------------|
84- | ` label ` | ` MaybeProp<String> ` | – | The accessible label for the icon. It will be visually hidden but announced to screen readers. |
85- | ` children ` | ` TypedChildren<impl IntoView + 'static> ` | – | Your icon (SVG or similar). Extra attributes like ` aria-hidden="true" ` and ` focusable="false" ` are automatically applied. |
86-
87- {{#endtab }}
88- {{#tab name="Yew" }}
89-
90- | Prop | Type | Default | Description |
91- | -------| ------| ---------| -----------------------|
92- | label | TODO | - | TODO for Yew support. |
93- | child | TODO | - | TODO for Yew support. |
59+ | Prop | Type | Default |
60+ | ------- | ---------------- | ------- |
61+ | ` label ` | ` Signal<String> ` | - |
9462
9563{{#endtab }}
9664{{#endtabs }}
9765
9866## Accessibility
9967
100- Most icons or icon systems come with no accessibility built-in. For example, the same visual ** cross** icon might mean *
101- * "close"** or ** "delete"** . By wrapping your icon in ` <AccessibleIcon::Root> ` (Leptos/Yew), you provide a meaningful
102- label that screen readers will announce, while the icon itself is hidden from assistive technology via
103- ` aria-hidden="true" ` .
104-
105- This is built with [ Visually Hidden] ( ../utilities/visually-hidden ) so labels are hidden visually but still accessible to
106- screen readers.
107-
108- ## Example (Leptos)
109-
110- ``` rust,ignore
111- use leptos::prelude::*;
112- use radix_leptos_visually_hidden::primitive as VisuallyHidden;
113- use radix_leptos_accessible_icon::primitive as AccessibleIcon;
114-
115- #[component]
116- fn CloseIcon() -> impl IntoView {
117- view! {
118- <AccessibleIcon::Root label="Close">
119- <svg width="24" height="24" viewBox="0 0 24 24">
120- <path d="M6 6 L18 18 M6 18 L18 6" stroke="currentColor" stroke-width="2" />
121- </svg>
122- </AccessibleIcon::Root>
123- }
124- }
125- ```
68+ Most icons or icon systems come with no accessibility built-in. For example, the same visual ** cross** icon may in fact mean ** "close"** or ** "delete"** .
69+ This component lets you give meaning to icons used throughout your app.
12670
127- > ** Yew ** : TODO – Provide a working example if/when the Yew version is complete .
71+ This is built with [ Visually Hidden ] ( ./visually-hidden.md ) .
12872
12973## See Also
13074
131- - [ Radix UI Accessible Icon documentation] ( https://www.radix-ui.com/primitives/docs/utilities/accessible-icon )
132- - [ Repository and more examples] ( https://github.com/RustForWeb/radix )
75+ - [ Radix documentation] ( https://www.radix-ui.com/primitives/docs/utilities/accessible-icon )
0 commit comments