Use Color Swatches...
- To provide a visual representation of available colors for selection.
- To allow users to compare and make more informed color decisions.
- To help users with color blindness to make accurate color choices by including textual labels.
Don't use Color Swatches...
- When color choice is not critical to the task as it can add clutter.
- As is when there is a large set of Color Swatches. Use Accordion with
skin="color-swatches"instead.
Always use the ColorSwatches wrapper to encase one or more ColorSwatch items to ensure they are properly styled.
Use an accessibleText attribute (for color-blind users) on each swatch. Its value is a localized description of the color choice, such as accessibleText="Light Blue".
The preview has been updated.
Sizes
size='super' is deprecated in SWAN v3.39
Use size='large' instead, which behaves the same, but better aligns with the new xlarge size.
The default size is ”standard”. Use when displaying swatches in a small container, such as a Tile. Use size=”large” or size="super" to display a bigger swatch, such as in filters or on a product page. Use size=”xlarge” in editing experiences or when a user may need to differentiate between similar shades of a color.
The preview has been updated.
Fill
By default, color swatches have a checkered background to represent transparency. Passing no color or the transparent keyword will render a checkered background. This works with other props, excluding gradient.
The preview has been updated.
Primary Color
Use primaryColor to display a one-tone swatch.
The preview has been updated.
Passing no color or the transparent keyword will render no visible color.
The preview has been updated.
Secondary Color
Use both primaryColor and secondaryColor to display a two-tone swatch.
The preview has been updated.
Tertiary Color
Use all three primaryColor and secondaryColor and tertiaryColor to display a three-tone swatch.
The preview has been updated.
Gradient
Use either gradient="linear" or gradient="radial" to display a two-tone or three-tone swatch as a gradient, rather than as two distinct color zones.
The preview has been updated.
Background Image
Use backgroundImage to display an image instead of a color.
The preview has been updated.
Label position
labelPosition is deprecated in SWAN v3.31
The tooltip now automatically selects the optimal placement. Providing one will be overridden by internal position placement evaluator.
Color Swatches More
Use ColorSwatchesMore, filling it with a + sign and a number, to indicate how many swatches are available, if there is not enough space to show them all.
The preview has been updated.
With a Selection Set
Selection Set is deprecated in SWAN v3.44.0
Use Choice Group with ChoiceColorSwatch instead. Set selectionMode="single" or selectionMode="multiple" depending on whether one or several colors can be selected. See Choice Group for more information.
Use a Selection Set to present a collection of color samples the customer can choose from.
- In the React API, add
as="span"to each swatch. - In the Vanilla API, use a
spantags for a valid HTML, since the swatches are insidelabeltags.
Refer to the Selection Set’s Accessibility documentation.
Radio Buttons
Use with variant="single-select" to prompt users to choose from a set of mutually-exclusive choices (Radio Button behavior).
The preview has been updated.
Checkboxes
Use with variant="multi-select" to prompt users to select more than one option (Checkbox behavior).
The preview has been updated.
With an Accordion
Refer to Accordion with skin="color-swatches" to wrap a large set of Color Swatches, to avoid making the content excessively tall.
Disabled
Use disabled on a ColorSwatch to prevent a color swatch from being selected. When a color swatch is temporarily unavailable or out of stock, to show that the option exists but cannot be selected at this time.
The preview has been updated.
With a Selection Set
The preview has been updated.
Accessibility
- Use the
accessibleTextprop (for color-blind users) on each color swatch. Its value is a localized description of the color choice, such asaccessibleText="Light Blue"