Type-safe React components for all HTML tags with full native attribute support.
@olympo/react-html-tags provides React components that wrap standard HTML elements with complete TypeScript support. Each component accepts all native HTML attributes for its corresponding tag and supports ref forwarding to the underlying DOM element.
- Full TypeScript Support: All components are fully typed using
JSX.IntrinsicElements - Ref Forwarding: Access underlying DOM elements via refs
- Native Attributes: All standard HTML attributes are supported
- Zero Dependencies: Only requires React 19+ as a peer dependency
- Tree-shakeable: Import only what you need
- Lightweight: Minimal wrapper around native HTML elements
npm install @olympo/react-html-tags
# or
yarn add @olympo/react-html-tags
# or
pnpm add @olympo/react-html-tags
# or
bun add @olympo/react-html-tagsimport { Div, Button, Input, Span } from '@olympo/react-html-tags';
function MyComponent() {
const inputRef = React.useRef<HTMLInputElement>(null);
const [value, setValue] = React.useState('');
return (
<Div className="container">
<Span style={{ fontSize: '18px', fontWeight: 'bold' }}>
Welcome!
</Span>
<Input
ref={inputRef}
type="text"
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder="Enter text..."
className="input-field"
/>
<Button
type="button"
onClick={() => inputRef.current?.focus()}
disabled={!value}
>
Submit
</Button>
</Div>
);
}All 110+ HTML5 elements are now supported! π
<Article>, <Aside>, <Div>, <Footer>, <Header>, <Hgroup>, <Main>, <Nav>, <Search>, <Section>
<H1>, <H2>, <H3>, <H4>, <H5>, <H6>
<Abbr>, <Address>, <B>, <Bdi>, <Bdo>, <Blockquote>, <Cite>, <Code>, <Data>, <Del>, <Dfn>, <Em>, <I>, <Ins>, <Kbd>, <Mark>, <P>, <Pre>, <Q>, <S>, <Samp>, <Small>, <Span>, <Strong>, <Sub>, <Sup>, <Time>, <U>, <Var>
<Dd>, <Dl>, <Dt>, <Li>, <Menu>, <Ol>, <Ul>
<A>, <Area>, <Link>, <Map>
<Button>, <Datalist>, <Fieldset>, <Form>, <Input>, <Label>, <Legend>, <Meter>, <Optgroup>, <Option>, <Output>, <Progress>, <Select>, <Textarea>
<Caption>, <Col>, <Colgroup>, <Table>, <Tbody>, <Td>, <Tfoot>, <Th>, <Thead>, <Tr>
<Audio>, <Canvas>, <Img>, <Picture>, <Source>, <Svg>, <Track>, <Video>
<Embed>, <Iframe>, <Object>, <Param>, <Portal>
<Details>, <Dialog>, <Summary>
<Rp>, <Rt>, <Ruby>
<Figcaption>, <Figure>
<Br>, <Hr>, <Wbr>
<Noscript>, <Slot>, <Template>
All components support:
- β
Full TypeScript typing via
JSX.IntrinsicElements - β Ref forwarding to underlying DOM elements
- β All native HTML attributes
- β Event handlers with proper typing
- β Comprehensive JSDoc documentation
All components provide full IntelliSense and type checking:
import { Input, Div } from '@olympo/react-html-tags';
// β
All native attributes are supported and type-checked
<Input type="email" required maxLength={100} />
// β
Ref forwarding is properly typed
const divRef = React.useRef<HTMLDivElement>(null);
<Div ref={divRef} />
// β TypeScript error: invalid attribute
<Input invalidProp="value" />For more examples, see the docs/example.tsx file which includes:
- Login form with input validation
- Interactive card component
- Counter button with ref manipulation
This library uses Bun for development:
# Install dependencies
bun install
# Run type checking
bun run typecheck
# Build the library
bun run buildContributions are welcome! We'd love your help making this library better.
Please read our Contributing Guide to learn about:
- How to set up your development environment
- Our code standards and component patterns
- The pull request process
- GitHub labels and issue tracking
- Component priority list
Quick guidelines:
- All components follow the established pattern
- TypeScript types are properly defined
- JSDoc comments are included
- Components remain lightweight wrappers
For detailed instructions, see CONTRIBUTING.md.
MIT