Text Selection
Text Selection is the marked text range. People select text to copy, replace, note, or edit it.
Select this useful phrase and keep the surrounding context.
A real example
A transcript editor keeps a sentence selected while opening a nearby annotation toolbar.
Main parts
- 01Visible label
- 02Interaction target
- 03Current state
- 04Keyboard behavior
Use it when
Keep native selection where people may quote, compare, copy, or edit useful text.
Do not use it when
Do not disable selection everywhere. Keep selection contrast clear, and do not make it look like keyboard focus.
Name used in code
Selection API / Range / ::selection Before you ship
Give assistive tools the control’s name (accessible name), purpose (role), value, and state. Check keyboard use, visible focus, target size, disabled and busy states, feedback, and recovery.
Outcome: Use Text Selection to solve this user need without losing the current context. User context: A transcript editor keeps a sentence selected while opening a nearby annotation toolbar. Recommended pattern: Text Selection. Why it fits: Keep native selection where people may quote, compare, copy, or edit useful text. Do not use it when: Do not disable selection everywhere. Keep selection contrast clear, and do not make it look like keyboard focus. Product requirements: Define the default, loading, empty, error, success, and recovery states. Keep user input. Give clear feedback after every action. Accessibility and resilience: Use semantic HTML, full keyboard access, and visible focus. Make the layout work when zoomed and support reduced motion. Follow the project’s current rules. Do not add a new UI library unless the project already uses it. Acceptance criteria: The main task works with keyboard only and at 320px width. Focus and status changes are announced. Check loading, failure, retry, cancel, and reduced-motion paths. Evidence and limits (evidence boundary): A formal document may still be a draft, release candidate, or final version. Check its status and browser or platform support. Unknowns to confirm: Product wording, data source, analytics events, supported devices and languages, and platform limits.
Check this request
Review the current use of Text Selection. Definition: Text Selection is the marked text range. People select text to copy, replace, note, or edit it. Release checks: Give assistive tools the control’s name (accessible name), purpose (role), value, and state. Check keyboard use, visible focus, target size, disabled and busy states, feedback, and recovery. Before changing code, report the evidence you found, gaps, severity, and the smallest safe fix.