Spacer
A utility component for adding consistent spacing between elements.
Installation
npm install @cleartrip/ct-design-spacer
# or
pnpm add @cleartrip/ct-design-spacer
Peer dependencies
# Required for all targets
npm install react
# Web only
npm install react-dom
# React Native only
npm install react-native
Usage
Basic
import { Spacer } from '@cleartrip/ct-design-spacer';
function Example() {
return (
<Spacer>
{/* Basic usage */}
</Spacer>
);
}
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
direction | SpacerDirectionType | 'horizontal' | No | Direction in which the space is applied. |
gap | `string | number` | — | No |
styleConfig | ISpacerStyleConfig | — | No | styleConfig slots for fine-grained style overrides. |
css | CSSProperties | — | No | existing overrides continue to win on web. |
as | `'main' | 'section' | 'article' | 'div' |
SpacerDirection
HORIZONTAL— horizontalVERTICAL— vertical
Accessibility
- The component follows accessibility best practices
- Ensure proper ARIA attributes are provided where needed
- Test with screen readers to ensure usability
Migration
If migrating from a previous version:
- import { Spacer } from 'yagami/core/components';
+ import { Spacer } from '@cleartrip/ct-design-spacer';