Repository navigation
Component Guidelines
Tiếng Việt: Component-Guidelines-vi.
The full, mandatory rules are in Design.md. This page is a
shortcut for when you start work.
- Open / pick up an issue (
confirmed, or an idea agreed on in Discussions Ideas). -
src/components/ui/<Name>/<Name>.tsx: a named function component that takesrefas a prop (noforwardRef, nodisplayName),classNamelast incn(), Vietnamese JSDoc. - Add
export * from "./<Name>/<Name>";to the right group insrc/components/ui/index.ts. - Docs page: add a
ComponentDocto asrc/docs/registry/*.tsxfile.slug,name,category,leadare string literals; each example'scodemust run when copied out (usesetupfor shared data). - English description:
<slug>: { lead: "…" }insrc/docs/i18n/en/components.ts(required by a test). - Tests:
<Name>.test.tsxnext to the component (behavior, keyboard, ARIA). Add an SSR case tosrc/test/ssrCases.tsxif some state depends on the environment. -
npx changeset→ chooseminor(new component) and write one sentence for users (in English). - Run the checklist in Testing and Quality + axe for your page:
npx playwright test e2e/a11y.spec.ts --project=a11y --grep "<slug>".
| Step | What | Files |
|---|---|---|
| 1 | Branch feat/quote-autocomplete from next (new feature → next) |
— |
| 2 | Components, reusing what already exists: SearchBox, listboxOptionClass, popoverSurfaceClass, normalizeSearchText, useSpinDelay
|
src/components/ui/Quote/, Autocomplete/
|
| 3 | Export into the right group of the barrel | src/components/ui/index.ts |
| 4 | Docs page, code trimmed with #region
|
src/docs/registry/content-search.tsx |
| 5 | English descriptions for the 2 slugs | src/docs/i18n/en/components.ts |
| 6 | Tests: diacritic-insensitive matching, ↓/Enter/Esc, combobox ARIA, <figure> semantics |
Autocomplete.test.tsx |
| 7 |
check:examples, check:props, axe by slug → fix the non-focusable scroll region that axe reported |
— |
| 8 | 2 minor changesets (one file per component); fixing the SearchBox example is docs only → no changeset |
.changeset/*.md |
| 9 | PR into next; the maintainer publishes 0.7.0-next.N when users should try it |
— |
Lessons learned: Radix Popover catches Esc at the document level before the input does, so close the popover through
onOpenChange, don't only listen to onKeyDown. Files may use CRLF, so bulk-editing scripts must normalize line endings.
| Wrong | Right |
|---|---|
bg-[#c2347a], p-[12px], duration-[200ms]
|
bg-brand-background, p-3, duration-normal
|
ml-2, left-0, text-left
|
ms-2, inset-s-0, text-start
|
start-4, data-[disabled]:, p-M
|
inset-s-4, data-disabled:, p-3 (npm run lint:classes -- --fix) |
outline-none with no replacement |
keep the focus ring focus-visible:outline-stroke-focus
|
| Directional icons that don't flip | rtl:-scale-x-100 |
Reading Date.now() / window / matchMedia during render |
an effect, or useSyncExternalStore + a server snapshot |
useLayoutEffect directly |
useIsomorphicLayoutEffect (_internal/) |
| Hand-written popup / menu | Radix primitive + usePortalThemeProps()
|
| Icon-only button with no name | Vietnamese aria-label
|
| Renaming a prop right away | add the new prop + warnDeprecated(), remove the old one in a major; see Versioning
|
Components beyond Fluent 2 (AI kit, Chart, Trace, DataGrid…) are in the Yugen Labs group, with their own rules in Design.md §7.1 (for example Chart: categorical colors in a fixed order, one Y axis, always an equivalent data table).
Yugen UI © trandat1114 · MIT · Inspired by Microsoft Fluent 2, not a Microsoft product · Edit the wiki through the wiki/ folder · Lấy cảm hứng từ Microsoft Fluent 2, không phải sản phẩm của Microsoft · Sửa wiki qua thư mục wiki/
Use
Develop
Project
Tiếng Việt
- Trang chủ
- Bắt đầu
- Theme & token
- Câu hỏi thường gặp
- Kiến trúc
- Viết component
- Kiểm thử & CI
- Viết nội dung
- Nhánh & kênh phát hành
- Phát hành
- Cộng đồng & phân loại
- Sổ tay vận hành
Links