-
Notifications
You must be signed in to change notification settings - Fork 43
docs: semantics docs #635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
docs: semantics docs #635
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fb7e8e8
add pages to nav
lancesnider 8b7007f
docs: semantics
lancesnider 4780d47
Add gif
lancesnider 2672d35
gordon feedback
lancesnider 9076479
update ea note
lancesnider 8220e09
add note on legacy text pages
lancesnider ddf82de
remove semantics docs from deprecated runtime/text pages
lancesnider 0d25d85
add feature support table
lancesnider 5fd50a3
Update feature support
lancesnider ff8ff10
Merge branch 'main' into accessibility
lancesnider b124ac6
gordon's feedback
lancesnider 3718f70
Merge branch 'main' into accessibility
lancesnider 92bf39c
re-add semantics fallback for web
lancesnider aa7d0c8
semantic inference
lancesnider 7f0afff
semantic tap is not inferred
lancesnider File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,215 @@ | ||
| --- | ||
| title: "Semantics" | ||
| description: "Make your experiences accessible to screen readers by defining semantic types, properties, states, and actions" | ||
| --- | ||
|
|
||
| <Note> | ||
| Semantics is currently only available in [Early Access](https://rive.app/downloads?utm_source=docs&utm_medium=content). Runtime support is in development or released as experimental. | ||
|
|
||
| Have feedback? Join the [Early Access community](https://community.rive.app/c/early-access/) to share your thoughts and help shape the feature. | ||
| </Note> | ||
|
|
||
| Semantics describe what an element is and how it should be understood. Adding semantics makes your experiences accessible, allowing screen readers to correctly describe and navigate your content. | ||
|
|
||
| **Architecture: Role / Trait / State / Actions** | ||
|
|
||
| - [Role](#semantic-role) — what the node is (button, checkbox, tab, etc.) | ||
| - [Properties](#semantic-properties) — additional information like label, value, or hint | ||
| - [Traits](#traits) — what the node can do (expandable, selectable, checkable, etc.) | ||
| - [State](#state) — what the node is doing (expanded, selected, checked, etc.) | ||
| - [Actions](#actions) - interactions triggered by the user (tap, increase, decrease) | ||
|
|
||
| <Note> | ||
| **Semantics at Runtime** | ||
|
|
||
| At runtime, semantics are converted into the platform’s accessibility system. | ||
|
|
||
| On web, this creates accessible DOM elements (for example, divs with roles and attributes). On iOS and Android, a semantic tree is generated and exposed to the system’s accessibility APIs. | ||
|
|
||
| Rive handles mapping your semantics to each platform automatically. For details on which runtimes currently support semantics, see [Feature Support](/feature-support). | ||
| </Note> | ||
|
|
||
| ## Adding Semantics | ||
|
|
||
|  | ||
|
|
||
| <Steps> | ||
|
lancesnider marked this conversation as resolved.
|
||
| <Step title="Add Semantics"> | ||
| Select an element in your scene. In the right sidebar, click the `+` button in the **Semantics** panel to enable semantics for that element. | ||
| </Step> | ||
| <Step title="Choose a Role"> | ||
| Use the dropdown to assign a [semantic role](#semantic-role), such as button, image, or heading. | ||
| </Step> | ||
| <Step title="Configure Properties"> | ||
| Update the element’s [semantic properties](#semantic-properties), [Traits](#traits), and [State](#state). | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| ### Semantic Role | ||
|
|
||
| The semantic role defines what the element *is* (for example, a button or image). Screen readers use this to describe the element and determine how it should behave. | ||
|
|
||
| Each role has different available [properties](#semantic-properties). | ||
|
|
||
| If your element doesn’t match a specific role, you can leave it set to **None**. | ||
|
|
||
| <Info> | ||
| Some elements, like text, automatically infer their semantic role. See [Semantic Inference](#semantic-inference) for more info. | ||
| </Info> | ||
|
|
||
| ## Semantic Properties | ||
|
lancesnider marked this conversation as resolved.
|
||
|
|
||
| Semantic properties provide additional information about an element, such as its label, value, or hint. | ||
|
|
||
| Available properties vary depending on the selected semantic role. | ||
|
|
||
| ### Label | ||
|
|
||
| The label describes what the element is or does. This is what screen readers announce. | ||
|
|
||
| For example, a slider that controls volume might have the label: | ||
| `Volume` | ||
|
|
||
| <Info> | ||
| Text elements automatically use their text content as the label. See [Semantic Inference](#semantic-inference) for more info. | ||
| </Info> | ||
|
|
||
| ### Heading (Text only) | ||
|
|
||
| Text elements can be marked as headings to define structure and hierarchy. | ||
|
|
||
| Options include **None** and **Heading 1** through **Heading 6**. | ||
|
|
||
| Headings help screen reader users navigate your content more easily. | ||
|
|
||
| <Info> | ||
| On web, Heading 1 maps to an `<h1>` element, Heading 2 to `<h2>`, and so on. | ||
| </Info> | ||
|
|
||
| ### Value (Inputs only) | ||
|
|
||
| Some elements, like sliders and switches, have a **Value** property that reflects their current state. | ||
|
|
||
| For example, a volume slider might have a value of `70%`. | ||
|
|
||
| Use data binding to keep the semantic value in sync with the visual state. | ||
|
|
||
| --- | ||
|
|
||
| ## Traits | ||
|
|
||
| Traits define what an element *can do*, while states describe what it is doing right now. | ||
|
|
||
| Some semantic roles include traits, such as **expandable** or **selectable**. Enabling a trait makes its corresponding [state](#state) available. | ||
|
|
||
| The lock icon indicates a required trait for that semantic role. For example, a checkbox always includes the **selectable** trait. | ||
|
|
||
|
|
||
| --- | ||
|
|
||
| ## State | ||
|
|
||
| States represent the current value of the node. | ||
|
|
||
| For example, an element with the **selectable** trait will have a **selected** state. | ||
|
|
||
| Some state flags are only meaningful when their corresponding trait is set. Without the trait, the platform sees the property as not applicable. | ||
|
|
||
| Keep semantic states in sync with your Rive file. For example, bind a boolean from your view model to the **toggled** state of a switch. You could also key the **toggled** state in a timeline. | ||
|
|
||
| ### Hidden | ||
|
|
||
| Hides the element from the accessibility tree. | ||
|
lancesnider marked this conversation as resolved.
|
||
|
|
||
| <Note> | ||
| Elements that are not visible (for example, hidden by layout or soloing) are automatically removed from the accessibility tree and do not require this property. | ||
|
|
||
| Use **Hidden** when an element is still present in the scene (for example, opacity is set to 0) but should not be exposed to assistive technologies. | ||
| </Note> | ||
|
|
||
| ### Disabled | ||
|
|
||
| Marks the element as disabled and not interactive. | ||
|
|
||
| ### Live Region | ||
|
|
||
| Indicates that the element’s content may update dynamically and should be announced by screen readers. | ||
|
|
||
| ## Actions | ||
|
|
||
| Semantic actions are interaction events triggered by assistive technologies. You can listen for these actions and update your experience in response. | ||
|
|
||
|
|
||
| ### Adding an Action | ||
|
|
||
| <Steps> | ||
| <Step title="Create a Listener"> | ||
| Select your object and [create a new Listener](/editor/state-machine/listeners). | ||
| </Step> | ||
| <Step title="Listen to a Semantic Action"> | ||
| With your listener selected, in the right sidebar choose **Semantic Action** in the **Listen to** dropdown. | ||
| </Step> | ||
| <Step title="Set the action type"> | ||
| Select the [action type](#types-of-actions) to listen for. | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| ### Types of Actions | ||
|
lancesnider marked this conversation as resolved.
|
||
|
|
||
| Actions include **tap**, **increase**, and **decrease**. Additional actions may be added in future releases. | ||
|
|
||
| #### Tap | ||
|
|
||
| Represents activating an element (similar to a click). | ||
|
|
||
| When a user activates an element using a screen reader, a **tap** action is triggered. You should listen for this action and handle it the same way as a standard click or pointer interaction. | ||
|
|
||
| <Note> | ||
| It’s common to add both a **Click** and a **Semantic Tap** listener to the same element to support pointer and assistive interactions. | ||
| </Note> | ||
|
|
||
| #### Increase / Decrease | ||
|
|
||
| Used for adjustable elements like sliders. | ||
|
|
||
| Users trigger these actions through assistive technologies—for example, by focusing a slider and swiping up or down with a screen reader, or using arrow keys on a keyboard. | ||
|
|
||
| You should listen for **increase** and **decrease** and update your value accordingly. | ||
|
|
||
|
|
||
| ### Semantic Inference | ||
|
|
||
| Some roles and properties are inferred based on the element they are applied to. | ||
|
|
||
| For example, when adding semantics to a text element, the [Role](#semantic-role) is set to **Text**, and the [Value](#value) is automatically derived from the element’s text content. | ||
|
|
||
| --- | ||
|
|
||
| ## Testing Semantics | ||
|
|
||
| Adding semantics is only the first step. You should always test your experience at runtime to make sure it behaves as expected. | ||
|
|
||
| Small issues—like a missing label or incorrect state—can make elements confusing or unusable for screen reader users. | ||
|
|
||
| ### Runtime Testing | ||
|
|
||
| The best way to test semantics is by using a screen reader. | ||
|
|
||
| - **macOS / iOS**: VoiceOver | ||
| - **Android**: TalkBack | ||
| - **Windows**: Narrator or NVDA | ||
|
|
||
| Turn on a screen reader and navigate through your experience: | ||
| - Move between elements | ||
| - Listen to how each element is announced | ||
| - Interact with buttons, sliders, and inputs | ||
|
|
||
| ### What to Check | ||
|
|
||
| As you test, pay attention to: | ||
|
|
||
| - **Labels** — Does each element clearly describe what it is or does? | ||
| - **Role** — Is the correct role announced (button, heading, etc.)? | ||
| - **Value** — Do dynamic elements (like sliders) report the correct value? | ||
| - **State** — Are states like selected, disabled, or expanded accurate? | ||
| - **Order** — Does navigation follow a logical flow? | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,6 @@ | ||
| ### Semantics for Accessibility | ||
|
|
||
| <Tip> | ||
| We recommend using [Data Binding](/editor/data-binding/overview) instead as | ||
| you'll be able to do a two-way text binding. | ||
| </Tip> | ||
|
|
||
| As Rive Text does not make use of the underlying platform text APIs, additional steps need to be taken to ensure it can be read by screen readers. | ||
| Rive now supports screen readers through semantics. | ||
|
|
||
| Please see the respective platform/SDKs developer documentation for additional information regarding accessibility concerns. | ||
| See the [Semantics](/editor/accessibility/semantics) documentation for current guidance. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.