OutlineBorder
A wrapper that adds an outline with optional clipping.
Usage
Outline Modes
Use ring-offset for avatar outlines and border when the outline should take up layout space.
Loading demo...
Mask Clipping
Use clip-mode="mask" for shapes that border radius cannot express, such as hexagons.
Loading demo...
Best Practices
- Prefer
overflowfor circular or rounded avatars; it is cheaper and easier to debug thanmask. - Use
ring-offsetwhen the outline needs a visible gap from the content. - Give the slotted content an explicit width and height so masks and rings keep a stable geometry.
- Use
as="span"only in inline contexts; keep block wrappers for cards, thumbnails, and list media.
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
as | string | 'div' | Root element tag. |
variant | 'border' | 'ring' | 'ring-offset' | 'ring-inset' | 'ring-offset' | Outline mode. |
shape | 'circle' | 'rect' | 'squircle' | 'circle' | Shape; sets the default radius and what clipShape="auto" resolves to. |
borderRadius | string | number | - | Explicit radius. |
borderWidth | string | number | '1px' | Border width; also the fallback ring width. |
borderColor | string | 'var(--tx-border-color)' | Border color; also the fallback ring color. |
borderStyle | 'solid' | 'dashed' | 'dotted' | 'solid' | Border style for variant="border". |
ringWidth | string | number | borderWidth | Ring width. |
ringColor | string | borderColor | Ring color. |
offset | string | number | '2px' | Gap width for variant="ring-offset". |
offsetBg | string | 'var(--tx-bg-color)' | Color of the gap. |
padding | string | number | 0 | Padding of the inner slot wrapper. |
clipMode | 'none' | 'overflow' | 'clipPath' | 'mask' | 'overflow' | Clipping strategy for the content layer. |
clipShape | 'auto' | 'circle' | 'rounded' | 'squircle' | 'hexagon' | 'auto' | Clip shape; auto maps shape to circle, rounded, or squircle. |
Slots
| Slot | Props | Description |
|---|---|---|
default | - | Content wrapped by the outline and the clipping layer. |
Overview
- The component has no intrinsic size; the slotted content sets the box. Numeric size props are treated as px.
variant="border"writes a real CSS border; ring variants usebox-shadowand don't affect layout size.clipMode:overflowclips throughborder-radius,clipPathwrites a CSSclip-path, andmaskwrites an inline SVG mask (circle,hexagon, andsquircleonly).- Under
clipPath,roundedandsquircleboth resolve toinset(0 round var(--tx-outline-radius)); the true squircle renders only withmask. - The outline follows only
border-radiusandclipShapeaffects only the content layer, so the outline doesn't tracehexagon/squircle; use a shapeddrop-shadowfilter when it must. - It is a visual wrapper only and adds no role, label, or image semantics; keep alt text, focus, and click targets on the slotted content.
Technologies
- The outline paints on the root and clipping applies to the content layer
.tx-outline-border__content; both share the radius through--tx-outline-radius. - Source:
packages/tuffex/packages/components/src/outline-border/.
查看源码
packages/tuffex/packages/components/src/outline-border/index.ts