stng-react
v2.0.0
Published
A React component library with SButton and SCard components
Downloads
1
Maintainers
Readme
Stng-react
A modern React component library built with TypeScript and styled with Tailwind CSS, featuring beautifully designed and accessible UI components.
Installation
npm install stng-reactRequirements
- React 18.0.0 or higher
- React DOM 18.0.0 or higher
Styling
This library uses Tailwind CSS for styling. The compiled CSS is automatically included when you import components, so you don't need to install Tailwind CSS separately in your project unless you want to extend or customize the styles.
If you're already using Tailwind CSS in your project, the components will seamlessly integrate with your existing Tailwind setup.
Components
SButton
A flexible button component with multiple variants and sizes, styled with Tailwind CSS.
import { SButton } from "stng-react";
function App() {
return (
<div>
<SButton
variant="primary"
size="medium"
onClick={() => console.log("Clicked!")}
>
Click me
</SButton>
<SButton variant="secondary" size="large">
Secondary Button
</SButton>
<SButton variant="danger" size="small" disabled>
Disabled Button
</SButton>
<SButton variant="success" size="medium">
Success Button
</SButton>
</div>
);
}Props
children: React.ReactNode - Button contentvariant: 'primary' | 'secondary' | 'danger' | 'success' - Button style variantsize: 'small' | 'medium' | 'large' - Button sizedisabled: boolean - Whether the button is disabledonClick: (event: React.MouseEvent) => void - Click handlertype: 'button' | 'submit' | 'reset' - Button typeclassName: string - Additional Tailwind CSS classes
SCard
A versatile card component for displaying content in a structured layout, built with Tailwind CSS utility classes.
import { SCard } from "stng-react";
function App() {
return (
<div>
<SCard
title="Card Title"
subtitle="Card subtitle"
variant="elevated"
padding="medium"
>
<p>This is the card content.</p>
</SCard>
<SCard
variant="outlined"
padding="large"
header={<div>Custom Header</div>}
footer={<div>Custom Footer</div>}
>
<p>Card with custom header and footer.</p>
</SCard>
</div>
);
}Props
children: React.ReactNode - Card contenttitle: string - Card titlesubtitle: string - Card subtitlevariant: 'default' | 'outlined' | 'elevated' - Card style variantpadding: 'none' | 'small' | 'medium' | 'large' - Card paddingclassName: string - Additional Tailwind CSS classesonClick: (event: React.MouseEvent) => void - Click handlerheader: React.ReactNode - Custom header contentfooter: React.ReactNode - Custom footer content
Customization
Since the components are built with Tailwind CSS, you can easily customize them by:
- Adding custom classes: Use the
classNameprop to add additional Tailwind classes - Extending with your own Tailwind config: If you're using Tailwind in your project, you can extend the default theme
- CSS-in-JS integration: The Tailwind classes work well with CSS-in-JS libraries
Example of customization:
<SButton
variant="primary"
className="shadow-xl transform hover:scale-105 transition-transform"
>
Custom Styled Button
</SButton>TypeScript Support
This library is built with TypeScript and includes complete type definitions for all components and their props.
License
MIT
