Alexa Styles and Resources (v1.1.0)
(This is not the most recent version of the alexa-styles
package. Use the Other Versions option to see the documentation for the most recent version of the alexa-styles
package)
Use the Alexa styles package to create a consistent presentation across different devices. This package provides a collection of named resources and styles designed to work well on different device types.
For details about defining your own resources and styles, see APL Resources and APL Styles.
Import the Alexa styles package
To use the Alexa styles package, and have access to all of its values, add the alexa-styles
package to the import
array in your document. The latest version of the alexa-styles
package is 1.6.0
.
Example of the imports
section of a document:
{
"import": [
{
"name": "alexa-styles",
"version": "1.6.0"
}
]
}
Color resources
The Alexa color resources define a set of colors. Use the "@" resource syntax to use these values on the color
property of an APL component, for example:
{
"type": "Text",
"color": "@colorText"
},
{
"type": "Frame",
"backgroundColor": "@colorBackground",
"borderColor": "@colorRed800"
}
Basic color resources
These resources define a set of color names. Many of these colors are also used within the UI color resources shown below.
Resource Name | Default |
---|---|
|
#000000 |
|
#0F0F0F |
|
#232F3E |
|
#FAFAFA |
|
#EBEDED |
|
#D6DBDB |
|
#ABB8B8 |
|
#879496 |
|
#6B7878 |
|
#383D3D |
|
#1E2222 |
|
#34581B |
|
#652718 |
|
#3E3F68 |
|
#65151E |
|
#652E2C |
|
#0A655E |
|
#FFFFFF |
|
#F0F0F0 |
|
#986300 |
UI element color resources
These resources define colors recommended for specific APL document elements, such as text and backgrounds. Note that some of these use the colors defined in Basic color resources.
The Default value is used for most viewports. The TV value is used for viewports that match the tvLandscapeXLarge
viewport profile.
Resource Name | Description | Default | TV |
---|---|---|---|
|
Use to draw attention to a UI component. |
#00C9FF |
Default |
|
Use for a basic background color. |
|
Default |
|
Color to use as an overlay over an image, to make text shown on top of the image easier to read. |
|
|
|
Use for a basic background color. |
|
Default |
|
The primary color for a component in its default state. For example, the default color of a button. |
|
#DADADA |
|
The primary color for a component in its default state. For example, the default color of a button. |
|
Default |
|
Default color for text elements. |
|
#DADADA |
|
Use for any disabled text, whether primary or secondary text. |
|
#DADADA |
|
Used for any disabled text, when displayed over elements with dramatically different color value than the background |
|
Default |
|
Use when standard text elements are displayed over elements with dramatically different color value than the background. |
|
Default |
|
Use to deemphasize metadata text. |
|
|
|
Use for metadata text which appears over elements with dramatically different color values than the background. |
|
Default |
Opacity resources
The opacity resources define numerical values you can use to set the opacity
property of a Component. Use the "@" resource syntax to use these values on the property, for example:
{
"type": "Text",
"text": "This text should appear disabled.",
"opacity": "@opacityDisabled"
}
Resource Name | Description | Value |
---|---|---|
|
Fade the component to appear disabled. |
0.3 |
|
Fade the component enough to make text shown on top of the component more readable. This level of opacity is often used with background images. |
0.6 |
Text resources
The text resources define values you can use to set properties on the Text
and EditText
components. Use the "@" resource syntax to set text properties to these values, for example:
{
"type": "Text",
"fontFamily": "@fontFamilyRomanSans",
"fontWeight": "@fontWeightBold",
"fontSize": "@fontSizeMedium",
"lineHeight": "@lineHeightExpanded",
"letterSpacing": "@letterSpacingNormal"
}
Font family
Use these string resources to set the fontFamily
property of the APL Text and APL EditText components.
Resource Name | Description | Value |
---|---|---|
|
Includes sans serifs used for English and English-like languages that are written in Latin, Greek, and Cyrillic scripts. |
Amazon Ember Display |
|
Includes serifs used for English and English-like languages that are written in Latin, Greek, and Cyrillic scripts. |
Bookerly |
|
Includes Chinese, Japanese, and Korean languages that are written in script languages where additional spacing may be needed for larger glyphs. |
Noto Sans CJK |
Font weight
Use these string resources to set the fontWeight
property of the APL Text and APL EditText components.
Resource Name | Description | Value |
---|---|---|
|
Use for most smaller text and any longer text. |
300 |
|
Use for karaoke text and text set at sizes below 18dp. |
400 |
|
Use for label text for titles. |
500 |
|
Use to create contrast and to highlight a number or part of a phrase. |
700 |
|
Use to create extreme contrast. |
900 |
Font size
Use these dimension resources to set the fontSize
property of the APL Text and APL EditText components. These resources are responsive, so they adjust in size based on the viewport of the user's device. The numerical values shown here are in dp
.
The Default value is used for most viewports. The Hub (small) value is used for viewports that match the hubRoundSmall
or hubLandscapeSmall
viewport profiles. The TV is used for viewports that match the tvLandscapeXLarge
viewport profile.
Resource Name | Description | Default | Hub (small) | TV |
---|---|---|---|---|
|
Use for quick, glanceable text, such as acronyms or large numbers to show time or day of the week. |
148 |
106 |
96 |
|
Slightly smaller display size to use for quick, glanceable text, such as acronyms or large numbers to show time or day of the week. |
112 |
80 |
64 |
|
Use when displaying a small amount of text, such as list items or inline titles that need to be read at a distance. |
92 |
66 |
48 |
|
Slightly smaller display size to use when displaying a small amount of text, such as list items or inline titles that need to be read at a distance. |
74 |
53 |
32 |
|
48 |
48 |
24 |
|
|
Use for text that is shown alongside text set in display sizes, such as a brief description to go alongside a movie title. |
40 |
40 |
20 |
|
Use for long-form content, such as a synopsis of a book. |
32 |
32 |
16 |
|
Use to accompany titles, such as a displaying additional metadata about a movie time. |
28 |
28 |
14 |
|
Use for navigation, page, and section headers, such as flight information in a header. |
24 |
24 |
12 |
Line height
Use these number resources to set the lineHeight
property of the APL Text component. These resources are responsive, so they adjust in size based on the viewport of the user's device.
The Default value is used for most viewports. The Hub (small) value is used for viewports that match the hubRoundSmall
or hubLandscapeSmall
viewport profiles. The TV is used for viewports that match the tvLandscapeXLarge
viewport profile.
Resource Name | Default | Hub (small) | TV |
---|---|---|---|
|
1.25 |
1.25 |
1.25 |
|
1.285 |
1.285 |
1.285 |
|
1.3 |
1.3 |
1.3 |
|
1.333 |
1.333 |
1.333 |
|
1.375 |
1.375 |
1.375 |
|
1.162 |
1.132 |
1.1667 |
|
1.117 |
1.15 |
1.125 |
|
1.173 |
1.151 |
1.166 |
|
1.297 |
1.207 |
|
|
1.297 |
1.207 |
|
Letter spacing
Use these number resources to set the letterSpacing
property of the APL Text component. These values increase or decrease the space between characters.
Resource Name | Description | Value |
---|---|---|
|
No extra space between characters. |
0 |
|
Decreases the space between characters. |
0.8 |
|
Increases the space between characters. |
2 |
Spacing resources
The spacing resources define dimension values you can use to set padding and spacing properties. Use the "@" resource syntax to set:
- The padding properties available on all components.
- The spacing properties
on the child components of a
Container
component.
The dimensions are expressed in dp.
For example:
{
"type": "Container",
"paddingLeft": "@spacingMedium",
"paddingRight": "@spacingMedium"
}
The Default value is used for most viewports. The Hub (large) value is used for viewports that match the hubLandscapeLarge
viewport profile. The TV is used for viewports that match the tvLandscapeXLarge
viewport profile.
Resource Name | Default | Hub (large) | TV |
---|---|---|---|
|
64 |
80 |
48 |
|
8 |
default |
4 |
|
12 |
default |
6 |
|
16 |
default |
8 |
|
24 |
default |
12 |
|
32 |
default |
16 |
|
48 |
default |
24 |
|
56 |
default |
28 |
|
64 |
default |
32 |
|
72 |
default |
36 |
Border radius resources
The border radius resources define dimension values you can use to set the borderRadius
property. Use the "@" resource syntax to use these values on the borderRadius
property of these components:
This lets you clip the corners of the image or frame. For example:
{
"type": "Image",
"borderRadius": "@shapeRoundedRect"
}
The Default value is used for most viewports. The TV is used for viewports that match the tvLandscapeXLarge
viewport profile.
Resource Name | Description | Default | TV |
---|---|---|---|
|
Round the corners of the image. |
8dp |
6dp |
|
Clip the image to a circle. This is set to the full viewport width to ensure that the value is a large enough number to clip the image to a circle. |
100vw |
default |
Text styles
Use the Alexa text styles to set the style
property of the APL Text component. These styles combine multiple text attributes such as color
, fontFamily
, fontSize
, and other attributes. These styles are defined to be responsive, so they work well across different devices.
Although other components also have a style
property, these styles specifically control Text
component properties, so it only makes sense to use them with the Text
component.
To assign a style to a Text
component, assign the style name to the component's style
property, for example:
{
"type": "Text",
"style": "textStyleDisplay4",
"text": "This text is using textStyleDisplay4."
}
The alexa-styles
package defines a base style (textStyleDisplayBase
) that sets all of the following Text
properties:
{
"color": "@colorText",
"fontFamily": "@fontFamilyRomanSans",
"fontStyle": "normal",
"lineHeight": "@lineHeightNormal",
"letterSpacing": "@letterSpacingNormal",
"opacity": 1
}
All remaining styles build off of this base.
Style Name | Description |
---|---|
|
Base text style, extended by the other styles. |
|
Use for glanceable text, such as acronyms, or large numbers to show time or day-of-the-week. |
|
Use to create contrast with |
|
Smaller than |
|
Use to create contrast with |
|
Use to display a small amount of text, such as list items to be read at a distance. |
|
Use to create contrast with |
|
Smaller than |
|
Use to create contrast with |
|
Use for text that is shown alongside an item, such as a brief description or synopsis of a movie. |
|
Use to create contrast with |
|
Use for headline text in paragraph or body copy. |
|
Use to create contrast with |
|
Use to highlight text in a karaoke experience. |
|
Use for long-form content, such as the synopsis of a book. |
|
Use to create contrast with |
|
Use for hint text or action hint text. |
|
Use for text that plays a supporting role, such as a grid view of images that each have a title. |
|
Use to create contrast with |
|
Used for button text that indicates that the button can be selected with the user's voice. |
|
Use for buttons and actionable touch controls. |
|
Use to accompany |
|
Use to create contrast with |
|
Use for optional UI elements, such as time passed in a progress bar. |
Related topics
- Responsive Components and Templates
- Alexa Design System for APL
- APL Text
- APL Style Definition and Evaluation
- APL Resources
Last updated: Nov 28, 2023