बटन ग्रुप
कुछ संबंधित बटनों को एक पंक्ति या एक कॉलम में रखता है, अलग-अलग दूरी पर या एक ही शेप में जोड़कर, काम पूरा करने वाली और पीछे हटने वाली क्रियाओं को वहाँ रखता है जहाँ लोग उनकी उम्मीद करते हैं, और बटनों को एक ग्रुप के रूप में नाम देता है।
- श्रेणी
- ऐक्शन
- टोकन
comp.button-group- स्तर
- आधार
- Web
tanrei-button-groupschedule - SwiftUI
TanreiButtonGroupschedule - Jetpack Compose
TanreiButtonGroupschedule - Flutter
TanreiButtonGroupschedule - React Native
ButtonGroupschedule
इससे जनरेट किया गया: docs/status/status.json, specs/button-group.spec.json
Standard और connected
आइटम वही बटन हैं जो आप पहले से इस्तेमाल करते हैं, लेबल वाले या सिर्फ़ आइकन वाले, अपनी प्रॉपर्टी और इवेंट के साथ। ग्रुप सिर्फ़ उन्हें जगह पर रखता है, connected होने पर उन्हें जोड़ता है, और लेबल होने पर उन्हें नाम देता है।
Web और React के उदाहरण मौजूदा स्पेक दिखाते हैं। SwiftUI, Compose, Flutter और React Native पीछे हैं: वे अभी बटन ग्रुप का पिछला संशोधन देते हैं, जो एक अकेली पंक्ति है, जिसमें orientation, fullWidth, separation या क्रम वाले फ़्लैग नहीं हैं, जिसके connected आइटम हमेशा एक सँकरे गैप की दूरी पर रहते हैं, और जिसके सिर्फ़ आइकन वाले आइटम एक अलग आइकन बटन हैं। जब तक वे बराबरी पर नहीं आते, उनके उदाहरण वही संशोधन दिखाते हैं।
<!-- dismissive पंक्ति के शुरू में जाता है, confirming उसके अंत में; कॉलम में दोनों जगह बदल लेते हैं। -->
<tanrei-button-group>
<tanrei-button variant="outlined" dismissive>रद्द करें</tanrei-button>
<tanrei-button variant="tonal">ड्राफ़्ट सेव करें</tanrei-button>
<tanrei-button variant="filled" confirming>प्रकाशित करें</tanrei-button>
</tanrei-button-group>
<!-- अपने कंटेनर जितना चौड़ा कॉलम: "अनुमति दें" "अभी नहीं" के ऊपर बनता है। -->
<tanrei-button-group orientation="vertical" full-width>
<tanrei-button variant="tonal" dismissive>अभी नहीं</tanrei-button>
<tanrei-button variant="tonal" confirming>अनुमति दें</tanrei-button>
</tanrei-button-group>
<!-- लेबल ग्रुप को नाम देता है। हर टॉगल अपना selected ख़ुद रखता है। -->
<tanrei-button-group variant="connected" label="टेक्स्ट स्टाइल">
<tanrei-button variant="tonal" toggle label="बोल्ड"><span slot="icon">format_bold</span></tanrei-button>
<tanrei-button variant="tonal" toggle label="इटैलिक"><span slot="icon">format_italic</span></tanrei-button>
<tanrei-button variant="tonal" toggle label="अंडरलाइन"><span slot="icon">format_underlined</span></tanrei-button>
</tanrei-button-group>
<script type="module">
import '@tanrei/web/components/button-group';
import '@tanrei/web/components/button';
// ग्रुप अपना कोई इवेंट फ़ायर नहीं करता: हर जगह की तरह, बटनों पर सुनें।
document.querySelector('[label="बोल्ड"]').addEventListener('change', (e) => setBold(e.detail.selected));
</script>import { Button, ButtonGroup } from '@tanrei/react';
// confirming और dismissive वे ऐट्रिब्यूट हैं जिन्हें ग्रुप अपने चाइल्ड से पढ़ता है।
<ButtonGroup>
<Button variant="outlined" dismissive onClick={cancel}>रद्द करें</Button>
<Button variant="tonal" onClick={saveDraft}>ड्राफ़्ट सेव करें</Button>
<Button variant="filled" confirming onClick={publish}>प्रकाशित करें</Button>
</ButtonGroup>
<ButtonGroup orientation="vertical" fullWidth>
<Button variant="tonal" dismissive onClick={notNow}>अभी नहीं</Button>
<Button variant="tonal" confirming onClick={allow}>अनुमति दें</Button>
</ButtonGroup>
<ButtonGroup variant="connected" label="टेक्स्ट स्टाइल">
<Button variant="tonal" toggle selected={bold} label="बोल्ड" onChange={(e) => setBold(e.detail.selected)}><span slot="icon">format_bold</span></Button>
<Button variant="tonal" toggle selected={italic} label="इटैलिक" onChange={(e) => setItalic(e.detail.selected)}><span slot="icon">format_italic</span></Button>
</ButtonGroup>import Tanrei
TanreiButtonGroup {
TanreiButton("रद्द करें", variant: .outlined) { cancel() }
TanreiButton("ड्राफ़्ट सेव करें", variant: .tonal) { saveDraft() }
TanreiButton("प्रकाशित करें") { publish() }
}
TanreiButtonGroup(variant: .connected, label: "टेक्स्ट स्टाइल") {
TanreiIconButton("बोल्ड", isSelected: $bold, variant: .tonal) { Image(systemName: "bold") }
TanreiIconButton("इटैलिक", isSelected: $italic, variant: .tonal) { Image(systemName: "italic") }
TanreiIconButton("अंडरलाइन", isSelected: $underline, variant: .tonal) { Image(systemName: "underline") }
}import io.github.chnotchy.tanrei.components.TanreiButton
import io.github.chnotchy.tanrei.components.TanreiButtonGroup
import io.github.chnotchy.tanrei.components.TanreiButtonGroupVariant
import io.github.chnotchy.tanrei.components.TanreiIconButton
import io.github.chnotchy.tanrei.primitives.TanreiText
import io.github.chnotchy.tanrei.tokens.TanreiButtonVariant
import io.github.chnotchy.tanrei.tokens.TanreiIconButtonVariant
TanreiButtonGroup {
TanreiButton(text = "रद्द करें", onClick = ::cancel, variant = TanreiButtonVariant.Outlined)
TanreiButton(text = "ड्राफ़्ट सेव करें", onClick = ::saveDraft, variant = TanreiButtonVariant.Tonal)
TanreiButton(text = "प्रकाशित करें", onClick = ::publish)
}
// contentDescription ग्रुप को नाम देता है। Compose में ग्रुप का कोई रोल नहीं है: यह एक ट्रैवर्सल ग्रुप है।
TanreiButtonGroup(variant = TanreiButtonGroupVariant.Connected, contentDescription = "टेक्स्ट स्टाइल") {
TanreiIconButton(
onClick = {},
contentDescription = "बोल्ड",
variant = TanreiIconButtonVariant.Tonal,
checked = bold,
onCheckedChange = { bold = it },
) { TanreiText("format_bold") }
TanreiIconButton(
onClick = {},
contentDescription = "इटैलिक",
variant = TanreiIconButtonVariant.Tonal,
checked = italic,
onCheckedChange = { italic = it },
) { TanreiText("format_italic") }
}import 'package:tanrei/tanrei.dart';
TanreiButtonGroup(
children: <Widget>[
TanreiButton(variant: TanreiButtonVariant.outlined, onPressed: cancel, child: const Text('रद्द करें')),
TanreiButton(variant: TanreiButtonVariant.tonal, onPressed: saveDraft, child: const Text('ड्राफ़्ट सेव करें')),
TanreiButton(onPressed: publish, child: const Text('प्रकाशित करें')),
],
);
TanreiButtonGroup(
variant: TanreiButtonGroupVariant.connected,
semanticLabel: 'टेक्स्ट स्टाइल',
children: <Widget>[
TanreiIconButton(
isSelected: bold,
onPressed: () => setState(() => bold = !bold),
variant: TanreiIconButtonVariant.tonal,
semanticLabel: 'बोल्ड',
icon: const Icon(AppSymbols.formatBold),
),
TanreiIconButton(
isSelected: italic,
onPressed: () => setState(() => italic = !italic),
variant: TanreiIconButtonVariant.tonal,
semanticLabel: 'इटैलिक',
icon: const Icon(AppSymbols.formatItalic),
),
],
);import { Button, ButtonGroup, IconButton } from '@tanrei/react-native';
<ButtonGroup>
<Button variant="outlined" onPress={cancel}>रद्द करें</Button>
<Button variant="tonal" onPress={saveDraft}>ड्राफ़्ट सेव करें</Button>
<Button onPress={publish}>प्रकाशित करें</Button>
</ButtonGroup>
<ButtonGroup variant="connected" accessibilityLabel="टेक्स्ट स्टाइल">
<IconButton variant="tonal" accessibilityLabel="बोल्ड" toggle selected={bold} onSelectedChange={setBold}>
format_bold
</IconButton>
<IconButton variant="tonal" accessibilityLabel="इटैलिक" toggle selected={italic} onSelectedChange={setItalic}>
format_italic
</IconButton>
</ButtonGroup>orientation बटनों को एक पंक्ति में रखता है (horizontal, डिफ़ॉल्ट) या उन्हें एक कॉलम में ऊपर-नीचे रखता है (vertical), जहाँ हर बटन कॉलम जितना चौड़ा होता है। fullWidth से ग्रुप अपने कंटेनर को भर देता है: पंक्ति के बटन चौड़ाई को बराबर बाँट लेते हैं, और कॉलम का हर बटन उतना ही चौड़ा होता है। किसी शीट या सँकरे पैनल के निचले हिस्से की क्रियाओं के लिए यही रूप है।
बटन पर लगे दो फ़्लैग ग्रुप को बताते हैं कि उसकी जगह कहाँ है, ताकि दोनों ओरिएंटेशन आपस में मेल खाते रहें:
| फ़्लैग | बटन | पंक्ति में | कॉलम में |
|---|---|---|---|
confirming |
काम को पूरा करता है: ठीक है, सेव करें, आगे, हटाएँ | अंत में | सबसे ऊपर |
dismissive |
उससे पीछे हटता है: रद्द करें, पीछे, अभी नहीं | शुरू में | सबसे नीचे |
| दोनों में से कोई नहीं | बाक़ी सब कुछ | इन दोनों के बीच, दिए गए क्रम में | इन दोनों के बीच, दिए गए क्रम में |
वही तीन बटन, एक पंक्ति में और एक कॉलम में
पूरी चौड़ाई: चौड़ाई बाँटने वाली पंक्ति, और एक कॉलम
कीबोर्ड फ़ोकस और स्क्रीन रीडर उसी क्रम में चलते हैं जिसमें बटन रखे गए हैं, इसलिए हर किसी को क्रियाएँ उसी क्रम में मिलती हैं जिसमें वे बनी हैं। फ़्लैग काम का वर्णन करते हैं, लहजे का नहीं: “रद्द करें · हटाएँ” में “हटाएँ” confirming वाला है। विनाशकारी क्रिया अपने रूप (Button के destructive) और लेबल से पहचानी जाती है, अपनी जगह से नहीं। डायलॉग और साइड शीट अपनी क्रियाओं को इन्हीं दो फ़्लैग से जगह देते हैं।
connected ग्रुप अपने बटनों को दो में से एक तरीक़े से जोड़ता है। डिवाइडर के साथ बटन एक-दूसरे को छूते हैं, जहाँ वे मिलते हैं वहाँ उनके कोने चौकोर होते हैं, और हर जोड़ पर एक रेखा होती है। गैप के साथ वे एक सँकरे गैप की दूरी पर रहते हैं, और जहाँ वे आमने-सामने होते हैं वहाँ उनके कोने ज़्यादा कसे हुए होते हैं। डिज़ाइन सिस्टम यह चुनाव एक बार उन सभी कंपोनेंट के लिए करता है जो भागों को जोड़ते हैं (डिफ़ॉल्ट सिस्टम डिवाइडर बनाता है), कोई डिज़ाइन सिस्टम बटन ग्रुप के लिए अलग चुनाव कर सकता है, और separation (auto, divider, gap) किसी एक ग्रुप के लिए इसे तय करता है। standard ग्रुप इसे अनदेखा करता है।
डिवाइडर से और गैप से जुड़े हुए, पंक्ति में और कॉलम में
डिवाइडर के साथ, जोड़ पर रेखा सिर्फ़ वहाँ होती है जहाँ दोनों बटन एक ही फ़िल पर टिके हों। चयनित और अचयनित टॉगल के बीच, या filled और outlined बटन के बीच, फ़िल का किनारा ही जोड़ को दिखा देता है, इसलिए वहाँ कोई रेखा नहीं बनती।
डिवाइडर से जुड़े टॉगल: चयनित टॉगल के बग़ल में कोई रेखा नहीं
Connected: outlined, large और एक अक्षम आइटम के साथ
संरचना
प्रॉपर्टी
| प्रॉपर्टी | टाइप | डिफ़ॉल्ट | विवरण |
|---|---|---|---|
variant | standard | connected | "standard" | standard spaces the Buttons apart. connected joins them into one shape with rounded outer ends, by a divider or by a narrow gap (separation), for a closely related set (Bold, Italic, Underline; Previous, Today, Next). |
orientation | horizontal | vertical | "horizontal" | horizontal lays the Buttons out in one row; vertical stacks them in one column, every Button as wide as the column. The confirming and dismissive Buttons change places with the orientation (BGR-13, BGR-14). |
separation | auto | divider | gap | "auto" | How the Buttons of a connected group are joined. divider: they touch, and a line is drawn on each seam. gap: they stand a narrow gap apart, with tighter corners where they face each other. Auto takes comp.button-group.connected.separation, the design system's answer (divider in the default system). Ignored while variant is standard. |
fullWidth | boolean | false | The group fills its container's width and its Buttons share it equally (in a column, each is the container's width). For the actions at the foot of a dialog, a picker or a side sheet. |
label | string | "" | The accessible name of the group ("Text style"). Optional: a group of actions that are each named by their own label needs none. |
आइटम
वे आइटम के प्रकार जिन्हें कंपोनेंट दोहराता है। फ़िक्स्चर अपने आइटम क्रम से सूचीबद्ध करता है; हर प्लैटफ़ॉर्म हर प्रकार को अपने तरीक़े से नाम देता है।
button
A Button in the group: the button component, placed, spaced and (when connected) given its corners and minimum size by the group, otherwise drawn and behaving as it does anywhere.
| प्रॉपर्टी | टाइप | डिफ़ॉल्ट | विवरण |
|---|---|---|---|
variant | filled | tonal | elevated | outlined | text | "filled" | Its emphasis, as the Button's variant. |
size | small | medium | large | "medium" | Its height, as the Button's size. Give every Button of a group the same size. |
width | default | narrow | wide | "default" | An icon-only Button's width, as the Button's width. A connected group still widens it to its minimum (BGR-3). |
icon | string | "" | The glyph in the Button's icon slot, by its name in the system's icon set. Empty for a label-only Button. It is how a fixture fills that slot; in an application the icon slot is filled as the Button's own spec says. |
iconPosition | leading | trailing | "leading" | Which side of the label the icon is on, as the Button's iconPosition. |
label | string | "" | Its accessible name, as the Button's label prop. Required for an icon-only Button. |
toggle | boolean | false | As the Button's toggle. |
selected | boolean | false | As the Button's selected. |
disabled | boolean | false | As the Button's disabled. |
confirming | boolean | false | The Button completes the task (OK, Save, Next, Delete). The group places it at the end of a row and at the top of a column (BGR-13, BGR-14). It changes the Button's place only, never its look (BGR-19). |
dismissive | boolean | false | The Button backs out of the task (Cancel, Back, Not now). The group places it at the start of a row and at the bottom of a column (BGR-13, BGR-14). It changes the Button's place only, never its look (BGR-19). |
| स्लॉट | विवरण |
|---|---|
label | Its label, as the Button's default slot. A fixture item's content is this label; an icon-only item has none. |
icon | Its glyph, as the Button's icon slot. A fixture fills it through the icon prop. |
| इवेंट | विवरण |
|---|---|
click | The Button was activated, as the Button's click. |
change | A toggle Button was switched, as the Button's change. |
| स्पेक | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
|---|---|---|---|---|---|
| आइटम | tanrei-button | TanreiButton | TanreiButton | TanreiButton | Button |
variant · प्रॉपर्टी | variant | variant | variant | variant | variant |
size · प्रॉपर्टी | size | size | size | size | size |
width · प्रॉपर्टी | width | width | width | width | width |
icon · प्रॉपर्टी | slot="icon" | icon | icon | icon | icon |
iconPosition · प्रॉपर्टी | iconPosition | iconPosition | iconPosition | iconAlignment | iconPosition |
label · प्रॉपर्टी | label | label | contentDescription | semanticLabel | accessibilityLabel |
toggle · प्रॉपर्टी | toggle | isSelected | onCheckedChange | isSelected | toggle |
selected · प्रॉपर्टी | selected | isSelected | checked | isSelected | selected |
disabled · प्रॉपर्टी | disabled | disabled | enabled | onPressed | disabled |
confirming · प्रॉपर्टी | confirming | tanreiGroupPlacement(.confirming) | Modifier.confirming() | TanreiButtonGroupItem.placement | confirming |
dismissive · प्रॉपर्टी | dismissive | tanreiGroupPlacement(.dismissive) | Modifier.dismissive() | TanreiButtonGroupItem.placement | dismissive |
click · इवेंट | click | action | onClick | onPressed | onPress |
change · इवेंट | change | isSelected | onCheckedChange | onPressed | onSelectedChange |
| टिप्पणियाँ | A tanrei-button child, as anywhere: its label is its content and its glyph a tanrei-icon in its icon slot. confirming and dismissive are boolean attributes on the child that the group reads (a MutationObserver re-places the items when they change, BGR-11); the Button itself draws nothing for them. | A TanreiButton child, as anywhere. A toggle is a Button given an isSelected binding. The two flags are one modifier, .tanreiGroupPlacement(.confirming) or (.dismissive), a LayoutValueKey the group's layout reads, as .layoutPriority is read by a stack; one enum cannot be both (BGR-18 cannot arise). | A TanreiButton child, as anywhere; a toggle is a Button given checked and onCheckedChange, and enabled is disabled's inverse. The two flags are modifiers of the group's scope, Modifier.confirming() and Modifier.dismissive(), parent data the group's layout reads, as RowScope.weight is. | A TanreiButton child, as anywhere; a null onPressed disables it, and a non-null isSelected makes it a toggle. The two flags are one ParentDataWidget, TanreiButtonGroupItem(placement: TanreiGroupPlacement.confirming | .dismissive, child:), as Flexible is for a Flex; one enum cannot be both (BGR-18 cannot arise). | A Button child, as anywhere. confirming and dismissive are props on the child that the group reads from its children; the Button itself draws nothing for them. |
स्टेट
व्यवहार
EARS रूप में लिखी गई आवश्यकताएँ। हर प्लैटफ़ॉर्म के इम्प्लीमेंटेशन को इन ID के आधार पर टेस्ट किया जाता है। आवश्यकताओं का पाठ स्पेक फ़ाइल से ज्यों का त्यों, अंग्रेज़ी में दिखाया गया है।
| ID | आवश्यकता |
|---|---|
BGR-1 | WHILE orientation is horizontal THE button group SHALL lay out its items in one row, in the order BGR-13 gives, each at its own size and width unless fullWidth is true (BGR-17): WHILE variant is standard comp.button-group.standard.gap apart and centred on the row's middle; WHILE variant is connected joined as its separation names (BGR-21) — comp.button-group.connected.gap apart under gap, touching under divider — and each stretched to the height of the tallest item (a Button's height is a minimum), so that the joined shape stays even when a label wraps or text is enlarged. |
BGR-2 | WHILE variant is connected and orientation is horizontal THE button group SHALL give the start corners of the first item and the end corners of the last the radius comp.button-group.connected.horizontal.outer-shape, and each corner that faces a neighbouring item the radius comp.button-group.connected.inner-shape WHILE its separation is gap and no radius, a square corner, WHILE its separation is divider (BGR-21), each capped at half the item's height and eased by sys.shape.corner-smoothing; the item's fill, outline, state layer, ripple and focus ring SHALL follow the resulting shape. WHILE variant is standard THE button group SHALL leave every corner of every item as the item draws it. |
BGR-3 | WHILE variant is connected THE button group SHALL make each item at least sys.target.touch for touch input and sys.target.pointer for fine pointers along the direction in which it meets its neighbours — wide in a row, high in a column — because joined items cannot extend a hit area over each other: an icon-only Button narrower than that widens its container around its centred icon, and a Button lower than that in a column grows its container around its centred content. Across the other direction the items SHALL extend their hit areas as BTN-5 says. A platform that cannot tell the input type SHALL use sys.target.touch. |
BGR-4 | WHILE variant is standard and the hit areas that two neighbouring items extend (BTN-5) overlap THE button group SHALL give every press on an item's visible bounds to that item, and a press in the gap between two items to the nearer one, so that neighbouring hit areas meet at the middle of the gap. comp.button-group.standard.gap is what keeps each item's target whole there: at sys.target.touch minus an item's width (in a row) or height (in a column) or more, no hit areas overlap and every item keeps its full target between its neighbours, as the default system's gap does for every Button size; a layer that narrows the gap narrows the targets between items. |
BGR-5 | THE button group SHALL NOT restyle its items beyond BGR-2, BGR-3, BGR-12, BGR-16, BGR-17, BGR-22 and BGR-23: each item SHALL render from its own tokens, answer hover, focus and press itself, switch itself WHILE its toggle is true, emit its own events, keep its own semantics and be its own Tab stop in the order BGR-15 gives; the group itself SHALL NOT take focus, SHALL NOT handle arrow keys and SHALL keep no selection of its own. |
BGR-6 | WHILE label is not empty THE button group SHALL expose itself to assistive technology as a group named by label that contains its items; WHILE label is empty THE button group SHALL expose no element of its own, only its items, unless the product names it (BGR-25). |
BGR-7 | WHERE orientation is horizontal, fullWidth is false and the row is wider than the space its layout gives it THE button group SHALL narrow its labelled Buttons in proportion to their widths, down to the width of their longest word, letting their labels wrap as a Button's label does when its layout gives it less width, and SHALL keep icon-only Buttons at their width; it SHALL NOT wrap the row onto a second line or scroll it, and in debug builds SHALL report a row that still does not fit. |
BGR-8 | WHEN the layout direction is right-to-left THE button group SHALL, in a row, put its start at the right — the dismissive items at the right and the confirming items at the left (BGR-13), the first placed item's outer corners on its right — and mirror which corners are inner corners; in a column it SHALL keep the top-to-bottom order of BGR-14. Each item's content SHALL follow the layout direction as the Button's does. |
BGR-9 | WHEN variant, orientation or separation names a value the button group does not define THE button group SHALL render with that prop's default (standard, horizontal, auto), and in debug builds report the unknown value. |
BGR-10 | WHILE the group holds fewer than two items, or content that is not a Tanrei Button, THE button group SHALL still render it, a single item keeping every corner as it draws it, and in debug builds report it; a platform that cannot inspect its content SHALL state the rule in its README and docs page. |
BGR-11 | WHEN an item becomes disabled, is added or is removed, or its confirming or dismissive changes, THE button group SHALL place its items again by BGR-13 and BGR-14 and recompute which corners are inner and outer corners, where its dividers are (BGR-24) and which items carry the outer padding of BGR-23, at once, without animation; a disabled item SHALL keep its place, its gap or its dividers, and its corners, and an item that has focus while it moves SHALL keep it. |
BGR-12 | WHILE orientation is vertical THE button group SHALL lay out its items in one column, top to bottom in the order BGR-14 gives, comp.button-group.standard.gap apart WHILE variant is standard and, WHILE variant is connected, comp.button-group.connected.gap apart under gap and touching under divider (BGR-21), and SHALL make every item as wide as the column — the widest item's width, or the container's width WHILE fullWidth is true — its content centred as a Button centres it in a wider container. WHERE the column is given less width than its widest item every item SHALL take that width and its label SHALL wrap as BGR-7 says; the column SHALL NOT scroll. |
BGR-13 | WHILE orientation is horizontal THE button group SHALL place its items from start to end in three runs: first the items whose dismissive is true, then the items with neither flag, then the items whose confirming is true; within each run the items SHALL keep the order they were given in. The start is the left in a left-to-right layout and the right in a right-to-left one (BGR-8). |
BGR-14 | WHILE orientation is vertical THE button group SHALL place its items from top to bottom in three runs: first the items whose confirming is true, then the items with neither flag, then the items whose dismissive is true; within each run the items SHALL keep the order they were given in, the first on top, in either layout direction. |
BGR-15 | THE button group SHALL make the focus order, and the order in which assistive technology reads its items, the placed order of BGR-13 and BGR-14 — start to end in a row, top to bottom in a column — whatever order the items were given in; a platform whose visual reordering the focus order does not follow (the web's CSS order) SHALL reorder the items themselves in the tree that focus and assistive technology walk. |
BGR-16 | WHILE variant is connected and orientation is vertical THE button group SHALL give the top corners of the first item and the bottom corners of the last the radius comp.button-group.connected.vertical.outer-shape, and every other corner of every item comp.button-group.connected.inner-shape WHILE its separation is gap and no radius, a square corner, WHILE its separation is divider (BGR-21), each capped at half the item's height and eased by sys.shape.corner-smoothing; the item's fill, outline, state layer, ripple and focus ring SHALL follow the resulting shape. |
BGR-17 | WHILE fullWidth is true and orientation is horizontal THE button group SHALL take the whole width its container gives it and divide it, less the gaps (none under divider), into equal shares, one per item, whatever each item holds: a label shorter than its share SHALL be centred in it, a label longer SHALL wrap as BGR-7 says, and an icon-only Button SHALL widen its container around its centred icon. WHERE a share is narrower than an item's minimum width (BGR-3, or an icon-only Button's own width) THE button group SHALL give that item its minimum, share the rest equally among the others, and in debug builds report it. WHILE fullWidth is false THE button group SHALL take its natural width. |
BGR-18 | IF an item's confirming and dismissive are both true THE button group SHALL place it among the items with neither flag and in debug builds report it. |
BGR-19 | THE button group SHALL NOT change an item's look, emphasis or semantics for its confirming or dismissive: the flags decide its place only. A destructive confirming action (Delete) takes its look from its own variant and its own destructive (BTN-40), and a Button is not made filled, or destructive, by being confirming. |
BGR-20 | THE button group SHALL take its layout direction from where it is used — the direction of the nearest ancestor that sets one, and the platform's own where none does — and SHALL have no direction setting of its own; WHEN that direction changes while the button group is shown THE button group SHALL draw itself for the new direction at once, without a motion of its own, keeping what it shows and its state. |
BGR-21 | WHILE variant is connected THE button group SHALL join its items as its separation names: WHILE separation is auto, as comp.button-group.connected.separation names, which follows sys.behavior.separation unless a design system sets it apart; WHILE separation is divider or gap, as that value names, whatever the tokens say. Under gap the items SHALL stand comp.button-group.connected.gap apart with nothing drawn between them and the inner corners of BGR-2 and BGR-16; under divider the items SHALL touch, with square inner corners and the divider of BGR-22 on each seam. WHILE variant is standard THE button group SHALL ignore separation and space its items by comp.button-group.standard.gap. WHEN separation, or the token it follows, changes THE button group SHALL draw the other form at once, without animation, keeping the order, the focus and the state of its items. A platform that cannot draw a choice SHALL fall back to the first value, divider, and state that in its README. |
BGR-22 | WHILE variant is connected and its separation is divider THE button group SHALL draw, on each seam between two neighbouring items that BGR-24 says carries one, a line comp.button-group.connected.divider.thickness thick, in the color BGR-24 names (comp.button-group.connected.divider.color, or comp.button-group.connected.divider.on-fill.color between two emphasis fills), centred on the seam, over the items' fills and state layers, running along the seam — top to bottom in a row, start to end in a column — and stopping comp.button-group.connected.divider.inset short of each end of it. The line SHALL take no space of its own, SHALL NOT take a press (a press on it goes to the item under the point), SHALL NOT be exposed to assistive technology and SHALL keep its color whatever state its neighbours are in. Each item SHALL draw neither its outline nor the ring of its elevation along an edge that meets a seam, whether or not a line is drawn on it, so that the divider is the only line a seam can carry and the outline of an outlined group runs once around the joined shape, in the color of its rules in the default system; an item's state layer, ripple and focus ring SHALL still follow that item's own shape. |
BGR-23 | WHILE variant is connected and orientation is horizontal THE button group SHALL add comp.button-group.connected.horizontal.outer-inset to the inline padding of the first item at its start and of the last item at its end, under either separation, so that content beside a rounded outer end looks as far from it as from the tighter corner on its other side: a labelled Button SHALL be wider by that amount with its content moved inward by it, and an icon-only Button SHALL be wider by that amount with its glyph centred in what is left, half of it nearer its neighbour. A single item (BGR-10) SHALL get none; a column SHALL add none, its ends not being full (BGR-16); WHILE fullWidth is true the shares of BGR-17 SHALL be divided first and the padding taken inside the end items' shares. In a right-to-left layout the start is the right, as BGR-8 says. |
BGR-24 | WHILE variant is connected and its separation is divider THE button group SHALL draw the line of BGR-22 on a seam only WHILE the two items it joins rest on the same fill: the colors from which they render their containers at rest — comp.button.outlined.container.color for an outlined Button, and so on for each variant, and for a toggle the selected or the unselected part of its variant (BTN-15) — are the same color in the active scheme, two containers that have no fill counting as the same. WHILE the two fills differ (a selected toggle beside an unselected one, a filled Button beside an outlined one) THE button group SHALL draw no line on that seam, because the edge of the fill already marks it, and the two items SHALL still draw neither outline nor elevation ring along it (BGR-22). A toggle of the text variant has no fill, selected or not, so its seams keep their lines. THE button group SHALL draw the line in comp.button-group.connected.divider.color, and in comp.button-group.connected.divider.on-fill.color WHILE both items rest on an emphasis fill: a filled Button that is not a toggle, or a selected toggle of the filled, tonal, elevated or outlined variant. It SHALL compare the fills the items have at rest: hover, focus and press SHALL neither add nor remove a line nor change its color, and a disabled item SHALL be compared by the look it has when enabled, so that disabling an item moves no line (BGR-11). WHEN an item's selected, toggle or variant changes THE button group SHALL add, remove or recolor the lines beside it at once, without animation. |
BGR-25 | WHERE the platform has ARIA attributes (the web), the host carries its group role (BGR-6) itself, so what the product writes on it is not moved, but for a name: WHILE label is not empty THE button group SHALL hold the product's aria-label and aria-labelledby on that host as their data-aria- twins, so that label is its whole name although the platform gives aria-labelledby the precedence, and WHEN label is emptied SHALL give them back as they were written; WHILE label is empty a name the product gives so — aria-label, or aria-labelledby naming an element — SHALL be its name. WHILE label is empty and the product names it so THE button group SHALL be exposed as a group named by that name, as with a label: a group the product names is a named group, and a name on an element with no role would name nothing. WHEN the product removes one, or its data-aria- twin, or sets the ARIA property that reflects it (ariaLabel, ariaLabelledByElements) to null, THE button group SHALL take it away. |
प्लैटफ़ॉर्म के अनुसार नामों का मिलान
पैरिटी का मतलब एक जैसे API नहीं है। हर प्लैटफ़ॉर्म एक ही कॉन्ट्रैक्ट को अपने तरीक़े से व्यक्त करता है।
| स्पेक | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
|---|---|---|---|---|---|
| कंपोनेंट | tanrei-button-group | TanreiButtonGroup | TanreiButtonGroup | TanreiButtonGroup | ButtonGroup |
variant · प्रॉपर्टी | variant | variant | variant | variant | variant |
orientation · प्रॉपर्टी | orientation | orientation | orientation | orientation | orientation |
separation · प्रॉपर्टी | separation | separation | separation | separation | separation |
fullWidth · प्रॉपर्टी | fullWidth | fullWidth | fullWidth | fullWidth | fullWidth |
label · प्रॉपर्टी | label | label | contentDescription | semanticLabel | accessibilityLabel |
| टिप्पणियाँ | <tanrei-button-group variant="connected" orientation="vertical" full-width label="Text style"> holds tanrei-button children. It places them without moving them in the author's DOM: its shadow root has three slots in the order of the orientation (dismissive, unflagged, confirming in a row; confirming, unflagged, dismissive in a column) and assigns each child to one with manual slot assignment, so focus and the accessibility tree, which walk the flat tree, follow the placed order (BGR-15) and CSS order is not used. It sets role group and aria-label on its own element only while label is not empty (ElementInternals is not used for the role: axe-core does not see semantics set through it). It gives a connected item its corners and minimum size through CSS custom properties that Button reads on its container (--tanrei-group-start-radius, --tanrei-group-end-radius, and in a column the top and bottom radii, --tanrei-group-min-width, --tanrei-group-min-height); these are an internal contract between Tanrei elements, not a styling API. Each item also learns its place in the group through an internal controller, because three things cannot be done with custom properties alone: a label that may wrap (BGR-7, BGR-17), corners that never animate and pill ends held to half the measured height (BGR-11), and a hit area that stops at half the gap (BGR-4). It reports other children in debug builds (BGR-10). separation is an attribute (auto, divider, gap); auto reads the name in --tanrei-comp-button-group-connected-separation. Under divider the group draws each rule itself, in its shadow root over the seam, and tells each item through the same internal controller which of its edges meet a seam (no outline, no ring) and how much padding to add at an outer end (BGR-22, BGR-23). Owed on the web: orientation="vertical" must really stack the items (BGR-12, BGR-14, BGR-16) — today the element and the review gallery draw every vertical fixture as a row — and its fixtures must be drawn as columns in the gallery and the baselines. | Lagging: ships an earlier revision, a row of Buttons and the retired icon-only kind with no orientation, placement flags or full width. The target: TanreiButtonGroup(variant:, orientation:, fullWidth:, label:) { TanreiButton … }, a custom Layout that places its subviews by BGR-13 and BGR-14 and gives them .accessibilitySortPriority in that order so VoiceOver and keyboard focus follow it (BGR-15). The group passes a connected item its corners and minimum size through an environment value that TanreiButton reads (internal to the package). With a label it is .accessibilityElement(children: .contain) with .accessibilityLabel(label). The group reads its content through a variadic view, as the menu and tabs do, so it reports fewer than two items and content that is not a Tanrei Button in debug builds (BGR-10). Also owed: separation (auto, divider, gap), the divider of BGR-22, the outer padding of BGR-23 and the nine new fixtures; reading comp.button-group.connected.separation as a typed choice needs the native token emitters to write a component's choice of kind as a typed enumeration, which they do not yet. | Lagging: ships an earlier revision, a row of Buttons and the retired icon-only kind with no orientation, placement flags or full width. The target: TanreiButtonGroup(variant, orientation, fullWidth, contentDescription) { TanreiButton(…) }, a custom Layout whose items read a CompositionLocal for their corners and minimum size (internal to the library). It places the items by BGR-13 and BGR-14 and sets traversalIndex in that order so TalkBack and focus follow it (BGR-15). With a content description it is semantics { isTraversalGroup = true; contentDescription = … }; Compose has no group role. Debug builds report content that is not a Tanrei Button, and a group of fewer than two items (BGR-10). Also owed: separation (auto, divider, gap), the divider of BGR-22, the outer padding of BGR-23 and the nine new fixtures; reading comp.button-group.connected.separation as a typed choice needs the native token emitters to write a component's choice of kind as a typed enumeration, which they do not yet. | Lagging: ships an earlier revision, a row of Buttons and the retired icon-only kind with no orientation, placement flags or full width. The target: TanreiButtonGroup(variant:, orientation:, fullWidth:, semanticLabel:, children: [TanreiButton(…)]), a MultiChildRenderObjectWidget that places its children by BGR-13 and BGR-14 and wraps each in a FocusTraversalOrder and Semantics(sortKey:) in that order (BGR-15); the items read an InheritedWidget for their corners and minimum size (internal to the package). With a label it is Semantics(container: true, label:, explicitChildNodes: true). Children of another type are reported in debug builds (BGR-10). Also owed: separation (auto, divider, gap), the divider of BGR-22, the outer padding of BGR-23 and the nine new fixtures; reading comp.button-group.connected.separation as a typed choice needs the native token emitters to write a component's choice of kind as a typed enumeration, which they do not yet. | Lagging: ships an earlier revision, a row of Buttons and the retired icon-only kind with no orientation, placement flags or full width. The target: <ButtonGroup variant orientation fullWidth accessibilityLabel>{…}</ButtonGroup> with Button children, which it renders in the order of BGR-13 and BGR-14 (reordering the children themselves, so focus and the screen reader follow it, BGR-15) and which read a React context for their corners and minimum size (internal to the package). With a label it has role="group" and accessibilityLabel; without one it adds no accessibility element. Children of another type are reported in development builds (BGR-10). Also owed: separation (auto, divider, gap), the divider of BGR-22, the outer padding of BGR-23 and the nine new fixtures; reading comp.button-group.connected.separation as a typed choice needs the native token emitters to write a component's choice of kind as a typed enumeration, which they do not yet. |
टोकन
| टोकन | किसका एलियास | रिज़ॉल्व किया गया मान (लाइट) |
|---|---|---|
--tanrei-comp-button-group-connected-divider-color | sys.color.outline-variant | |
--tanrei-comp-button-group-connected-divider-inset | sys.space.space100 | 8px |
--tanrei-comp-button-group-connected-divider-on-fill-color | sys.color.outline | |
--tanrei-comp-button-group-connected-divider-thickness | sys.border.hairline | 1px |
--tanrei-comp-button-group-connected-gap | sys.space.space25 | 2px |
--tanrei-comp-button-group-connected-horizontal-outer-inset | sys.space.space50 | 4px |
--tanrei-comp-button-group-connected-horizontal-outer-shape | sys.shape.corner.full | 9999px |
--tanrei-comp-button-group-connected-inner-shape | sys.shape.corner.small | 6px |
--tanrei-comp-button-group-connected-separation | sys.behavior.separation | 0 |
--tanrei-comp-button-group-connected-vertical-outer-shape | sys.shape.corner.large | 12px |
--tanrei-comp-button-group-standard-gap | — | 16px |
फ़िक्स्चर
मानक रेंडरिंग। हर प्लैटफ़ॉर्म हर फ़िक्स्चर का स्नैपशॉट एक ही ID से लेता है, ताकि नतीजों की तुलना की जा सके।
standard
variant: standard items: 3 standard-icon-only
variant: standard label: Post actions items: 3 standard-mixed
variant: standard label: Message actions items: 3 connected
variant: connected label: Clipboard items: 3 connected-divider
variant: connected separation: divider label: Clipboard items: 3 connected-gap
variant: connected separation: gap label: Clipboard items: 3 connected-divider-filled
variant: connected separation: divider label: Clipboard items: 3 connected-gap-filled
variant: connected separation: gap label: Clipboard items: 3 connected-divider-tonal
variant: connected separation: divider label: Clipboard items: 3 connected-divider-elevated
variant: connected separation: divider label: Clipboard items: 3 connected-toggles
variant: connected label: Text style items: 3 connected-gap-toggles
variant: connected separation: gap label: Text style items: 3 connected-outlined-toggles
variant: connected separation: divider label: Text style items: 3 connected-mixed
variant: connected label: Date items: 4 connected-large
variant: connected label: Date items: 3 connected-disabled
variant: connected label: Clipboard items: 3 connected-vertical
variant: connected orientation: vertical label: Calendar view items: 3 connected-vertical-gap
variant: connected orientation: vertical separation: gap label: Calendar view items: 3 connected-vertical-toggles
variant: connected orientation: vertical label: Zoom items: 2 vertical-unflagged
variant: standard orientation: vertical items: 3 order-cancel-ok
variant: standard items: 2 order-cancel-ok-vertical
variant: standard orientation: vertical items: 2 order-back-next
variant: standard items: 2 order-back-next-vertical
variant: standard orientation: vertical items: 2 order-three-runs-vertical
variant: standard orientation: vertical items: 3 order-rtl
variant: standard direction: rtl items: 2 full-width
variant: standard fullWidth: true items: 2 full-width-vertical
variant: standard orientation: vertical fullWidth: true items: 2 इससे जनरेट किया गया: specs/button-group.spec.json, tokens/comp/button-group.tokens.json, design/tokens/
बटन ग्रुप तब इस्तेमाल करें जब कुछ बटन एक साथ के हों: फ़ॉर्म का अंत (“रद्द करें”, “ड्राफ़्ट सेव करें”, “प्रकाशित करें”), एडिटर की फ़ॉर्मैटिंग (“बोल्ड”, “इटैलिक”, “अंडरलाइन”), कैलेंडर के “पिछला”, “आज” और “अगला”। ग्रुप उनकी स्पेसिंग तय करता है, जब वे एक सेट हों तो उन्हें जोड़ता है, और जहाँ इससे मदद मिले वहाँ उन्हें नाम देता है। हर बटन एक बटन ही रहता है।
मौजूदा स्क्रीन या चयन के लिए क्रियाओं की वह पंक्ति, जिस तक एक ही Tab स्टॉप से पहुँचा जाता है और जिसमें ऐरो कुंजियाँ एक से दूसरी क्रिया पर ले जाती हैं, एक टूलबार है। अपने ही अलग-अलग रूपों के मेन्यू से जुड़ी मुख्य क्रिया एक मेन्यू वाला बटन है: वह दो बटनों के connected ग्रुप जैसा दिखता है, पर उसका दूसरा आधा हिस्सा हमेशा एक मेन्यू खोलता है।
ये चारों कुछ संबंधित चीज़ों को एक पंक्ति में रखते हैं, इसलिए इनमें आसानी से भ्रम हो जाता है। फ़र्क़ इसमें है कि दबाने पर क्या होता है और कीबोर्ड इनके भीतर कैसे चलता है।
| कंपोनेंट | यह क्या है | चयन | कीबोर्ड | किसके लिए इस्तेमाल करें |
|---|---|---|---|---|
| सेगमेंटेड बटन (Material और cupertino प्रीसेट; Tanrei सिस्टम में नहीं) | एक कंट्रोल: आपस में जुड़े दो से पाँच विकल्प, जो एक ही सवाल का जवाब देते हैं। | इसका अपना, मान के आधार पर: एक विकल्प, या कई। | एक Tab स्टॉप। ऐरो कुंजियाँ विकल्पों के बीच ले जाती हैं, और एकल चयन में वे चुनती भी हैं। | कुछ तय जवाबों वाली सेटिंग, जो तुरंत लागू होती है: दिन, हफ़्ता, महीना; बाएँ, बीच में, दाएँ। |
| बटन ग्रुप | अलग-अलग बटनों की एक पंक्ति या एक कॉलम, अलग-अलग दूरी पर या एक ही शेप में जुड़े हुए। | कोई नहीं। ग्रुप का टॉगल बटन अपना चालू या बंद स्टेट ख़ुद रखता है। | हर बटन अपना अलग Tab स्टॉप है। | संबंधित क्रियाएँ: रद्द करें, ड्राफ़्ट सेव करें, प्रकाशित करें; एक-दूसरे से स्वतंत्र टॉगल के रूप में बोल्ड, इटैलिक और अंडरलाइन। |
| चिप | एक पंक्ति में अलग-अलग छोटे कंट्रोल, जो अगली पंक्ति में जाती है या स्क्रॉल होती है। | हर फ़िल्टर चिप अपने आप में चालू या बंद होता है। | हर चिप अपना अलग Tab स्टॉप है। | लिस्ट के ऊपर के फ़िल्टर, सुझाए गए जवाब, व्यक्ति के डाले हुए आइटम। |
| टैब | एक ही विषय के व्यू, हर एक अपने पैनल के साथ। | एक टैब: वह व्यू जो स्क्रीन पर है। | एक Tab स्टॉप। ऐरो कुंजियाँ ले जाती हैं और चुनती हैं। | यह बदलना कि कौन-सा कॉन्टेंट दिखे: अवलोकन, गतिविधि, सेटिंग। |
एक झटपट कसौटी: अगर उसे दबाने से कुछ होता है, तो वह बटन ग्रुप है। अगर वह नीचे का कॉन्टेंट बदलता है, तो वह टैब है। अगर वह एक मान सेट करता है, तो वह रेडियो बटन है, या जहाँ सिस्टम सेगमेंटेड बटन देता है वहाँ सेगमेंटेड बटन। जो विकल्प बहुत सारे हों या एक-दूसरे से स्वतंत्र हों, वे चिप हैं।
| वेरिएंट | यह क्या करता है | किसके लिए |
|---|---|---|
| Standard (डिफ़ॉल्ट) | बटनों को एक-दूसरे से दूरी पर रखता है, इतनी कि हर बटन अपने पड़ोसियों के बीच अपना पूरा टच टार्गेट बनाए रखे। हर बटन अपने कोने ख़ुद रखता है। | वे क्रियाएँ जो साथ बैठती हैं पर अपने आप में अलग हैं, जैसे फ़ॉर्म के “रद्द करें” और “सेव करें”। |
| Connected | बटनों को गोल बाहरी सिरों वाले एक शेप में जोड़ता है, डिवाइडर से या सँकरे गैप से (डिवाइडर से जुड़े या गैप से देखें)। हर बटन कम से कम एक टार्गेट जितना चौड़ा होता है और सबसे ऊँचे बटन जितना खिंचता है। | आपस में गहराई से जुड़ा सेट, जो एक ही कंट्रोल जैसा दिखता है: बोल्ड, इटैलिक, अंडरलाइन; पिछला, आज, अगला। |
connected ग्रुप में सिर्फ़ वे कोने बदलते हैं जो किसी पड़ोसी की ओर हैं: डिवाइडर के साथ चौकोर, गैप के साथ ज़्यादा कसे हुए। फ़िल, आउटलाइन, स्टेट लेयर, रिपल और फ़ोकस रिंग जुड़े हुए शेप के अनुसार चलते हैं, और जुड़ी हुई पंक्ति के गोल बाहरी सिरों को थोड़ी ज़्यादा पैडिंग मिलती है, ताकि सिरों के बटनों का कॉन्टेंट बराबर बैठा हुआ दिखे। सिर्फ़ आइकन वाला small बटन अपने बीच में रखे आइकन के इर्द-गिर्द टार्गेट की चौड़ाई तक चौड़ा हो जाता है, क्योंकि जुड़े हुए बटन एक-दूसरे के ऊपर तक नहीं पहुँच सकते।
डिफ़ॉल्ट रूप से पंक्ति इस्तेमाल करें। कॉलम वहाँ इस्तेमाल करें जहाँ बटन अपने पूरे लेबल के साथ अगल-बग़ल न समाएँ, जैसे किसी सँकरी शीट या फ़ोन जितने चौड़े पैनल की क्रियाएँ, या ऊपर से नीचे चलने वाले कॉन्टेंट के बग़ल में, जैसे नक़्शे के ज़ूम कंट्रोल। काम पूरा करने वाले बटनों और उससे पीछे हटने वाले बटनों को चिह्नित करें, ताकि लेआउट के पंक्ति और कॉलम के बीच बदलने पर भी क्रम वही रहे जिसकी लोग उम्मीद करते हैं।
- ग्रुप के हर बटन को एक ही साइज़ दें।
- एम्फ़ेसिस वैसे ही ख़र्च करें जैसे कहीं भी करते हैं: ज़्यादा से ज़्यादा एक filled बटन, आम तौर पर अंत में।
- ग्रुप को लेबल तब दें जब उसके बटन सिर्फ़ साथ में ही समझ आते हों, जैसे “टेक्स्ट स्टाइल”। क्रियाओं की उस पंक्ति के लिए इसे छोड़ दें जिसकी हर क्रिया ख़ुद बताती है कि वह क्या करती है।
- connected ग्रुप के बटनों के लिए एक ही वेरिएंट इस्तेमाल करें, ताकि जुड़ा हुआ शेप एक ही चीज़ जैसा दिखे।
- काम पूरा करने वाले बटन को
confirmingऔर उससे पीछे हटने वाले बटन कोdismissiveचिह्नित करें, और उन्हें जगह देने का काम ग्रुप पर छोड़ दें। उन्हें किसी भी क्रम में लिखें; ग्रुप आपके मार्कअप में उन्हें नहीं खिसकाता। separationकोautoपर ही रहने दें, जब तक कि किसी एक ग्रुप को अलग न होना हो, ताकि प्रॉडक्ट का हर जुड़ा हुआ कंट्रोल एक ही तरीक़े से अलग पहचाना जाए।
- एक-दूसरे को बाहर करने वाले चुनावों के लिए, जैसे बाएँ, बीच में और दाएँ अलाइनमेंट, ग्रुप में टॉगल बटन इस्तेमाल न करें। ग्रुप यह पक्का नहीं करता कि उसके टॉगल में से एक ही चालू रहे। जहाँ चुनाव नीचे का कॉन्टेंट बदलता है वहाँ टैब, जहाँ वह एक मान सेट करता है वहाँ रेडियो बटन, या जहाँ सिस्टम सेगमेंटेड बटन देता है वहाँ सेगमेंटेड बटन इस्तेमाल करें।
- ग्रुप में Tanrei के Button के सिवा, लेबल वाले या सिर्फ़ आइकन वाले, कुछ और न रखें: न फ़ील्ड, न चिप, न मेन्यू। डीबग बिल्ड दूसरे कॉन्टेंट की रिपोर्ट करते हैं।
- फ़्लैग का इस्तेमाल लहजे के लिए न करें। काम पूरा करने वाला विनाशकारी “हटाएँ”
confirmingहै, और उसका रूप उसके अपनेdestructiveसे आता है; दोनों फ़्लैग वाला बटन ऐसे रखा जाता है मानो उस पर कोई फ़्लैग न हो, और उसकी रिपोर्ट की जाती है। - यह उम्मीद न करें कि पंक्ति टूटकर दूसरी पंक्ति में जाएगी। जो पंक्ति नहीं समाती, वह अपने Button को सँकरा करती है और उनके लेबल को अगली पंक्ति में ले जाती है। वह कभी दूसरी पंक्ति में नहीं जाती और न स्क्रॉल होती है।
- एक ग्रुप में अलग-अलग साइज़ न मिलाएँ। ग्रुप अपने बटनों का साइज़ नहीं बदलता।
- रोल
group- लेबलिंग
- label, when given, names the group ("Text style"). Each item is named as it is anywhere: a Button by its label text, an icon-only Button by its label prop.
- न्यूनतम टार्गेट
- दिखने वाला आकार छोटा होने पर भी हिट एरिया न्यूनतम टार्गेट साइज़ को पूरा करता है। minimum 32px · pointer 44px · spacing 8px · touch 48px
कीबोर्ड
| कुंजियाँ | क्रिया |
|---|---|
| Tab / Shift+Tab | Moves focus to each enabled item in turn in the placed order (BGR-15): start to end in a row, top to bottom in a column. |
| Enter / Space | Activates the focused item, as the Button itself says (a toggle switches). |
टिप्पणियाँ
- A button group is a layout of actions: each item is its own Tab stop with its own semantics. A row that should be one Tab stop with arrow keys is a toolbar; one choice among several is a single-selection control: tabs where it changes the content below, a radio group where it sets a value, or a segmented button in a system that ships one.
- A toggle Button in a group keeps its own on/off state; the group does not make its toggles exclusive. One choice among several is a single-selection control: tabs where it changes the content below, a radio group where it sets a value, or a segmented button in a system that ships one.
- confirming and dismissive are not announced: they decide where a Button is, and focus and reading follow that place, so a screen-reader user meets the actions in the same order a sighted user sees them.
- The two flags describe the task, not the tone: in "Cancel · Delete" Delete is confirming. A destructive action is told apart by its own look (the Button's destructive) and its label, not by its place.
- Compose has no group role: the group is a traversal group whose content description is label, and each item keeps its own role.
- Text size: Buttons in a group grow as they do anywhere; a connected row stretches every item to the tallest, and a column makes every item as wide as the widest.
- A divider is decoration: it is not exposed, takes no press and is no boundary a person must find. What tells two joined Buttons apart for assistive technology is that each is its own button with its own name; for sight, their content and the line or the gap between them.
- A seam between a selected and an unselected toggle carries no line: the fill of the selected item ends there, at a contrast far above 3:1 against its neighbour, and that edge is the boundary. The selected state itself is exposed by the toggle (BTN-14), never by the line.
- In the default system the outline of an outlined group and its rules are the hairline (the divider's color), far below 3:1 against the surface. That is within WCAG 1.4.11: each Button is identified by its label or its icon, not by its edge.
इससे जनरेट किया गया: specs/button-group.spec.json, tokens/sys/measure.tokens.json
- हर बटन अपना रोल, नाम, स्टेट और Tab स्टॉप ख़ुद रखता है। Tab उनमें उसी क्रम में चलती है जिसमें वे रखे गए हैं: पंक्ति में शुरू से अंत तक, कॉलम में ऊपर से नीचे तक। ग्रुप न फ़ोकस लेता है, न ऐरो कुंजियाँ सँभालता है, न कोई चयन रखता है।
confirmingऔरdismissiveपढ़कर नहीं सुनाए जाते। वे तय करते हैं कि बटन कहाँ है, और फ़ोकस और पढ़ने का क्रम उसी जगह के अनुसार चलते हैं।- डिवाइडर सजावट है: वह सहायक तकनीक से छिपा रहता है और दबाना नहीं लेता। जुड़े हुए दो बटनों को जो चीज़ अलग पहचान देती है, वह यह है कि हर एक अपने नाम वाला अपना अलग बटन है।
- लेबल के साथ, ग्रुप सहायक तकनीक को उसी नाम वाले एक ग्रुप के रूप में मिलता है, जिसके भीतर उसके बटन हैं। लेबल के बिना वह एक्सेसिबिलिटी ट्री में कुछ नहीं जोड़ता।
- connected ग्रुप में हर बटन कम से कम एक टार्गेट जितना चौड़ा होता है, और उसका हिट एरिया पंक्ति के ऊपर और नीचे न्यूनतम टार्गेट तक पहुँचता है। standard ग्रुप में, बटन की दिखने वाली सीमा के भीतर दबाना हमेशा उसी बटन को जाता है, और गैप में दबाना नज़दीक वाले बटन को।
- फ़ोकस इंडिकेटर हर बटन के शेप के अनुसार चलता है, जुड़े हुए कोनों समेत।
- बड़े टेक्स्ट साइज़ पर बटन वैसे ही बढ़ते हैं जैसे कहीं और। connected पंक्ति हर बटन को सबसे ऊँचे बटन जितना खींचती है, और कॉलम हर बटन को सबसे चौड़े बटन जितना चौड़ा बनाता है, ताकि जुड़ा हुआ शेप एक-सा रहे।
- डिफ़ॉल्ट सिस्टम में outlined ग्रुप की आउटलाइन और उसके डिवाइडर बारीक रेखा हैं, जो जान-बूझकर हल्की रखी गई है: हर बटन की पहचान उसके लेबल या उसके आइकन से होती है, उसके किनारे से नहीं।
- डीबग बिल्ड इन बातों की रिपोर्ट करते हैं: दो से कम आइटम वाला ग्रुप, ऐसा कॉन्टेंट जो Tanrei का Button नहीं है, दोनों फ़्लैग वाला बटन, अनजान वेरिएंट, ओरिएंटेशन या separation, पूरी चौड़ाई वाली वह पंक्ति जिसके बटन चौड़ाई को बराबर नहीं बाँट सकते, और वह पंक्ति जो अपने Button के सँकरे हो जाने के बाद भी नहीं समाती।
प्लैटफ़ॉर्म की ज्ञात कमियाँ:
- Web: connected आइकन बटन बारीक पॉइंटर (जैसे माउस) के साथ पॉइंटर टार्गेट जितना चौड़ा होता है, और मोटे पॉइंटर के साथ टच टार्गेट जितना। जहाँ आइटम का अपना शेप पिल है, वहाँ पड़ोसी की ओर के उसके कोने कॉर्नर स्मूदिंग से नरम किए हुए नहीं, बल्कि गोलाकार होते हैं। ग्रुप के भीतर Button का लेबल अगली पंक्ति में जा सकता है; ग्रुप के बाहर वह एक ही पंक्ति में रहता है। जो पंक्ति फिर भी नहीं समाती, उसकी रिपोर्ट तब जाँची जाती है जब ग्रुप का साइज़ बदलता है या उसके चाइल्ड बदलते हैं, तब नहीं जब किसी आइटम का लेबल बदलता है।
- SwiftUI में ग्रुप का कोई रोल नहीं है। लेबल वाला ग्रुप अपने लेबल के नाम वाला एक कंटेनर है, जिसमें उसके बटन रहते हैं। जिस Button का शीर्षक
LocalizedStringKeyहै, जैसा कि स्ट्रिंग लिटरल होता है, वह अपने सबसे लंबे शब्द से भी ज़्यादा सँकरा किया जा सकता है, और तब वह शब्द बीच से टूट जाता है। जो पंक्ति फिर भी नहीं समाती, उसकी रिपोर्ट डीबग बिल्ड में एक असर्शन फ़ेल्यर है, इसलिए जो लेआउट पल भर के लिए बहुत सँकरा हो जाता है, जैसे वह कंटेनर जिसकी चौड़ाई ऐनिमेट होती है, वह डीबग ऐप को रोक देता है। - Compose में ग्रुप का कोई रोल नहीं है। लेबल वाला ग्रुप एक ट्रैवर्सल ग्रुप है जिसका कॉन्टेंट डिस्क्रिप्शन वही लेबल है, और हर बटन अपना रोल ख़ुद रखता है।
- React Native: iOS और Android दो बटनों के बीच के गैप में दबाने को कैसे बाँटते हैं, बड़े टेक्स्ट साइज़ पर connected ग्रुप के खिंचे हुए बटन कैसे दिखते हैं, और फ़ोकस के ग्रुप में आने पर VoiceOver और TalkBack उसका नाम पढ़कर सुनाते हैं या नहीं, यह किसी डिवाइस पर जाँचा नहीं गया है।
- React Native: सँकरा किया गया Button अपने सबसे लंबे शब्द से भी छोटा हो सकता है, और तब उस शब्द के अक्षर कई पंक्तियों में टूट जाते हैं, क्योंकि React Native के लेआउट में टेक्स्ट के लिए कॉन्टेंट की कोई न्यूनतम चौड़ाई नहीं है।
- standard ग्रुप में हिट एरिया गैप के बीचोबीच मिलते हैं। डिफ़ॉल्ट सिस्टम का गैप (16) इतना चौड़ा है कि हर आइकन बटन, small समेत, अपने पड़ोसियों के बीच अपना पूरा 48 का टच टार्गेट बनाए रखता है। सँकरे गैप वाला डिज़ाइन सिस्टम बटनों के बीच के टार्गेट को सँकरा कर देता है।
- हर आइकन बटन को नाम दें। ग्रुप का लेबल उसके भीतर के बटनों को नाम नहीं देता।
- ग्रुप को पढ़ने के क्रम में वहाँ रखें जहाँ उसके बटनों की जगह है। सहायक तकनीक उन तक एक-एक करके पहुँचती है, उसी क्रम में जिसमें वे आते हैं।
- अगर टॉगल के किसी सेट में एक समय में एक ही चालू रहना ज़रूरी है, तो एकल चयन वाला कंट्रोल इस्तेमाल करें: जहाँ चुनाव नीचे का कॉन्टेंट बदलता है वहाँ टैब, जहाँ वह एक मान सेट करता है वहाँ रेडियो बटन, या जहाँ सिस्टम सेगमेंटेड बटन देता है वहाँ सेगमेंटेड बटन। इनमें से हर एक को एक चुनाव के रूप में पढ़कर सुनाया जाता है; टॉगल बटनों की पंक्ति को नहीं।