ui-redpanda
v0.2.9
Published
Visit [Red Panda Studio](https://red-panda.studio/redpandaui) for visual examples.
Downloads
249
Readme
Visit Red Panda Studio for visual examples.
GitHub
- Clone the project down.
git clone https://github.com/TimothyRedPanda/redpanda-ui.git
- Move into the correct directory.
cd ./redpanda-ui
- Install the dependencies and build the project.
npm install
- Run Storybook to view full UI components documentation.
npm run storybook
Getting Started
- Install Red Panda UI into your React project.
npm i ui-redpanda@latest
- Import your desired component and the styles.
import { Button /* Or the component of your choice */ } from 'ui-redpanda';
import "ui-redpanda/dist/style.css";
- Use the component.
import { Button, Switch, Label, Input, Textbox } from "ui-redpanda";
import "ui-redpanda/dist/style.css";
const App = () => {
return (
<div>
<Button>Default</Button>
<Switch />
<Label label="Your label here"/>
<Input type="text" sanitized/>
<Textbox name="Your text box" placeholder="Type here..." />
</div>
);
};
export default App;
Components
Each component has a className
prop if you wish to add your own class. Just to allow you to reference it in CSS
if you wish. Remember though any styles you apply in CSS
will have to have the !important
tag.
.yourClass {
/* !important is needed to override the default styles. */
background-color: #fff !important;
}
Button
Props
The Button component accepts the following props:
children
(ReactNode, required): The content to be displayed inside the button.onClick
(function, optional): The function to be called when the button is clicked.variant
(string, optional): The style variant, can becontained
,outlined
ordisabled
.size
(string, optional): Size of the button, can besmall
,base
(default size) orlarge
.
Switch
Props
The Switch component accepts the following props:
onClick
(function, optional): The function to be called when the switch is toggled.variant
(string, optional): The style variant, can belive
ordisabled
.
Label
Props
The Label component accepts the following props:
label
(string, required): The actual text the label says.size
(string, optional): Text size, can besmall
,base
(default size) orlarge
.
Input
Props
The Input component accepts the following props:
type
(string, required): The type of the input, e.g.,text
,checkbox
,radio
,number
ordate
.defaultValue
(string, optional): The default value of the input.className
(string, optional): Additional class names for styling the input.onChange
(function, optional): The function to be called when the input value changes.onClick
(function, optional): The function to be called when the input is clicked.sanitized
(boolean, optional): If you simply -<Input sanitized/>
. Then any text input will be sanitized. If you wish to do your own sanitization then simply leave this off.
Textbox
Props
The Textbox component accepts the following props:
rows
(number, optional): The number ofrows
for the textarea. Default is4
.cols
(number, optional): The number of columns for the textarea. Default is50
.name
(string, optional): The name attribute of the textarea. Default is "textbox".className
(string, optional): Additional class names for styling the textarea.onChange
(function, optional): The function to be called when the textarea value changes.sanitized
(boolean, optional): If set to true, the input will be sanitized to prevent special characters, HTML, and other potentially dangerous inputs.placeholder
(string, optional): The placeholder text for the textarea. Default is "Text area...".
Sanitization
Can be toggled on Textbox
and Input
components -
- Escape special characters.
- HTML tags.
- Script tags.
- Event handlers.
- CSS expressions.