Make Toggle labels slottable (#1002)

* feat(toggle): support slottable labels

* yarn build:lib

* docs(toggle): add "Slottable labels" example
This commit is contained in:
Eric Liu 2022-01-12 16:43:27 -10:00 committed by GitHub
commit 32edfa59dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 3 deletions

View file

@ -12440,6 +12440,18 @@
}
],
"slots": [
{
"name": "labelA",
"default": false,
"fallback": "{labelA}",
"slot_props": "{}"
},
{
"name": "labelB",
"default": false,
"fallback": "{labelB}",
"slot_props": "{}"
},
{
"name": "labelText",
"default": false,

View file

@ -27,6 +27,15 @@ components: ["Toggle", "ToggleSkeleton"]
<Toggle labelText="Push notifications" labelA="No" labelB="Yes" />
### Slottable labels
An alternative to the "labelA" and "labelB" props is to use the corresponding named slots.
<Toggle labelText="Push notifications">
<span slot="labelA" style="color: red">No</span>
<span slot="labelB" style="color: green">Yes</span>
</Toggle>
### Disabled
<Toggle labelText="Push notifications" disabled />