Skip to content
Browse documentation
whisk/ui

Focus styles

Make keyboard focus visible and consistent across custom interactive surfaces.

Focus model

Use semantic controls and a visible keyboard focus treatment together.

Whisk/UI applies _focus to :focus-visible:not(:disabled). It appears for keyboard navigation without adding a focus treatment to every pointer click.

Prefer Button, Link, and native form controls for interactive content. Use a custom host only when it has the correct semantic element and keyboard behavior.

Focus examples

Pair a focus border with a shadow so focus remains visible without moving the layout.

import { Box, Text } from "@smoothie-framework/whisk-react";

export function SaveChangesControl() {
  return (
    <Box
      as="button"
      padding={3}
      background="surface2"
      border="sm"
      borderColor="border"
      rounded="md"
      _focus={{ borderColor: "borderFocus", shadow: "md" }}
    >
      <Text>Save changes</Text>
    </Box>
  );
}

Focus checklist

Check focus with a keyboard in every supported theme before shipping a custom interactive surface.

  • Keep the focus treatment visible in both light and dark themes.
  • Use more than color alone to show focus.
  • Do not remove the browser focus outline unless an equivalent treatment replaces it.

See the Accessibility foundation for keyboard interaction and contrast guidance.