CSS basic user interface
The CSS basic user interface module lets you define the rendering and functionality of features related to the user interface including outline properties, visual feedback to pointing device and keyboard, and altering the default appearance of UI widgets.
Basic user interface properties can be used to improve user experience and accessibility by providing visual cues to elements that are being interacted with, including styling mouse cursors and keyboard directional focus navigation, and styling caret cursors when an editable element has focus. The module provides for providing outlines to focused (or not) elements without impacting an element's box model dimensions and styling. This UI module also enables the styling of user interface controls.
Basic user interface in action
To view how basic user interface properties can alter the appearance of UI features, interact with the elements in this sample. Note that some features in this sample improve usability while others harm user experience.
The CSS outline
and outline-offset
properties were used to provide feedback to users which element currently has focus. An accent-color
provides a theme color to all the form controls. The caret that appears when the text is edit has the same color thanks to the caret-color
property. These can all be considered UI improvements.
Some features harm usability. The cursor
property was used to change cursors from the browser default which is confusing. The resize
property prevents the second <textarea>
from being resizable while the pointer-events
property prevents the third <textarea>
from receiving click events. It is still focusable using the keyboard.
Click "Play" in the example above to see or edit the code for the animation in the MDN Playground.
Reference
Properties
accent-color
appearance
-
caret
, shorthand for: cursor
nav-down
nav-left
nav-right
nav-up
-
outline
, shorthand for: outline-offset
pointer-events
resize
user-select
Guides
- Learn forms: advanced form styling
-
Explains how
appearance
can be used to style form controls.
Related concepts
- CSS
cursor
property - SVG
cursor
attribute - CSS
:focus
,:focus-within
, and:focus-visible
pseudoclasses CaretPosition
Interface
Specifications
Specification |
---|
CSS Basic User Interface Module Level 4 |