Styling

in Carousels Tutorial

Button Size

Use appropriately sized buttons and links, and provide whitespace around them, to allow people with reduced dexterity to use the carousel more easily. This also benefits people using touch screens, such as on mobile devices. Buttons and links that are not inline in a block of text should be at least 44 × 44 CSS pixels.

Contrast

Example using semi-transparent background colors to ensure sufficient contrast. Ensure sufficient contrast between the foreground and the background of text, links, and buttons. This can be a challenge when text or buttons are positioned on top of images. In that case, a (semi-) opaque background color can help to maintain the contrast regardless of the image used.

For more information on contrast requirements, see Provide sufficient contrast between foreground and background.

Indicate Button Status

Since the navigation buttons added to the carousel are typically small, it is important to indicate their status both in color and shape (in addition to proper naming and labeling). This makes it easier for people to differentiate the buttons and their current status.

In the following example, a filled square is used for buttons associated with items currently not shown. The button for the item shown has rounded corners and inverted colors. When users hover over these buttons using a mouse or focus them using a keyboard, their border is dotted.

A working demo example for this code is available.

For smaller screens/small viewports

Ensure all text is readable and not cut off or unnecessarily truncated. Make sure that navigation buttons to control the slides are available, since some people cannot use swipe gestures.

Back to Top