Switch
- Web Components
- Flutter
Demo
zeta-web v0.6.6
Web Components
Switches toggle the state of a single item ON or OFF. To use with icon variant, provide both activeIcon and inactiveIcon
Storybook
https://design.zebra.com/web/storybook/?path=/docs/components-switch--docs
Attributes
Name | Description | Type | Default |
---|---|---|---|
activeIcon | Icon name to display when switch is ON. | ZetaIconName | undefined | undefined |
inactiveIcon | Icon name to display when switch is OFF. | ZetaIconName | undefined | undefined |
Inherited Attributes
Name | Description | Type | Default | Inherited From |
---|---|---|---|---|
autoCapitalize | Whether inputted text is automatically capitalized and how. Only takes effect on non-keyboard entry | "none" | "off" | "sentences" | "on" | "words" | "characters" | undefined | undefined | BaseToggleFormElement |
autoComplete | AutoFill | undefined | undefined | BaseToggleFormElement | |
name | The name of the form control. | string | "" | BaseToggleFormElement |
id | The id of the form control. | string | "" | BaseToggleFormElement |
required | Indicates whether the form control is required to be filled out before submitting the form. | boolean | false | BaseToggleFormElement |
value | The value of the Form Control that is submitted when part of a form. | string | null | null | BaseToggleFormElement |
checked | The state of the Switch or Checkbox that is submitted when part of a form. | boolean | undefined | BaseToggleFormElement |
indeterminate | The state of the Switch or Checkbox defined by a mixed or unknown state. | boolean | false | BaseToggleFormElement |
placeholder | Placeholder text shown when value is empty. | string | undefined | undefined | BaseToggleFormElement |
min | The minimum value for number inputs | number | undefined | undefined | BaseToggleFormElement |
max | The maximum value for number inputs | number | undefined | undefined | BaseToggleFormElement |
readOnly | Placeholder text shown when value is empty. | boolean | undefined | undefined | BaseToggleFormElement |
spellCheck | Whether to spellcheck the input | boolean | "default" | undefined | undefined | BaseToggleFormElement |
disabled | Boolean for if component is disabled.This will apply disabled styles. | boolean | false | BaseToggleFormElement |
tabIndex | The tab index of the component, used to determine the order in which elements receive focus when the user navigates through the document by pressing the Tab key. | number | 0 | BaseToggleFormElement |
rounded | Whether the component is rounded or sharp.When true, rounded will set the border radius of the first child, and any children with class 'contourable-target' to --radius-minimal .Otherwise, this value will be --radius-none . | boolean | undefined | true | BaseToggleFormElement |
CSS Properties
Name | Description |
---|---|
--switch-track-color | Color of the switch track |
--switch-track-active-color | Color of the switch track when switch is ON |
--switch-track-disabled-color | Color of the switch track when switch is disabled |
--switch-icon-color | Color of the activeIcon & inactiveIcon |
--switch-icon-disabled-color | Color of the activeIcon & inactiveIcon when disabled |
--switch-thumb-color | Color of the switch thumb |
--switch-thumb-disabled-color | Color of the switch thumb when disabled |
--switch-height | Height of the switch |
--switch-width | Width of the switch |
--switch-thumb-size | Height & Width of the switch thumb |
--switch-icon-size | Height & Width of the activeIcon & inactiveIcon |
Demo
Zeta Switch.
Widgetbook
https://design.zebra.com/flutter/widgetbook/index.html#/?path=components/switch/zetaswitch/web
Inheritance
Object
> DiagnosticableTree
> Widget
> StatelessWidget
Constructors
Constructor for ZetaSwitch.
ZetaSwitch.new({Key? key, bool? value = false, ValueChanged<bool?>? onChanged, ZetaSwitchType? variant})
Properties
Name | Description | Type | Features |
---|---|---|---|
hashCode | The hash code for this object. | int | no setter inherited |
key | Controls how one widget replaces another widget in the tree. | Key? | final inherited |
onChanged | Called when the value of the switch should change. | ValueChanged<bool?>? | final |
runtimeType | A representation of the runtime type of the object. | Type | no setter inherited |
value | Determines whether the switch is on or off. | bool? | final |
variant | Variant of switch for different platforms. | ZetaSwitchType? | final |
Methods
Name | Description | Type | Features |
---|---|---|---|
build(BuildContext context) | Describes the part of the user interface represented by this widget. | Widget | override |
createElement() | Creates a StatelessElement to manage this widget's location in the tree. | StatelessElement | inherited |
debugDescribeChildren() | Returns a list of DiagnosticsNode objects describing this node's children. | List<DiagnosticsNode> | inherited |
debugFillProperties(DiagnosticPropertiesBuilder properties) | Add additional properties associated with the node. | void | override |
noSuchMethod(Invocation invocation) | Invoked when a nonexistent method or property is accessed. | dynamic | inherited |
paddingAll(double space) | Available on Widget, provided by the SpacingWidget extension | Widget | undefined |
paddingBottom(double space) | Available on Widget, provided by the SpacingWidget extension | Widget | undefined |
paddingEnd(double space) | Available on Widget, provided by the SpacingWidget extension | Widget | undefined |
paddingHorizontal(double space) | Available on Widget, provided by the SpacingWidget extension | Widget | undefined |
paddingStart(double space) | Available on Widget, provided by the SpacingWidget extension | Widget | undefined |
paddingTop(double space) | Available on Widget, provided by the SpacingWidget extension | Widget | undefined |
paddingVertical(double space) | Available on Widget, provided by the SpacingWidget extension | Widget | undefined |
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) | Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. | DiagnosticsNode | inherited |
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) | A string representation of this object. | String | inherited |
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) | Returns a string representation of this node and its descendants. | String | inherited |
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) | Returns a one-line detailed description of the object. | String | inherited |
toStringShort() | A short, textual description of this widget. | String | inherited |
Figma