1.0.5 • Published 3 years ago

custom-themed-button v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Custom Themed Button

A buttons package that works best with styled-components. so set up your styled-components theme if you haven't already and keep on reading!

Alt Text

CodeSandbox playground: https://codesandbox.io/s/custom-themed-button-sandbox-r6ei7?file=/src/App.tsx

npm i custom-themed-button
// Set up your styled-components theme
export const theme = {
  main: '#39A2DB',
  mainDark: '#053742',
  mainLight: '#A2DBFA',
  sec: '#FFA900',
  secDark: '#E2703A',
  secLight: '#E6DD3B',
  error: '#D44000',
};

// Wrap your app with the <ThemeProvder> and pass your theme
import { ThemeProvider } from 'styled-components';

function App() {
  return <ThemeProvider theme={theme}>...App Children</ThemeProvider>;
}

// The Button Components wil be available anywhere in your app!
import { Button } from 'custom-themed-button';

function Example() {
  return (
    <div>
      <Button text="Custom Themed Button" color="main" bgColor="sec" />
    </div>
  );
}

Note that when we pass color props to the Button component, we use the same names as in the theme object.

Let's review the available props:

Required props:

propvalueDescriptiondefaultrequired?
textstringButton text.noneno
colorstringFont color. The name of the color as written in the theme object. e.g color='main'noneyes
bgColorstringBackground color. The name of the color as written in the theme object. e.g bgColor='main'noneyes

Styling Props:

propvalueDescriptiondefaultrequired?
size'xs', 'sm', 'md', 'lg', 'xl'Background color. The name of the color as written in the theme object.'md'no
iconanyIcon to display in the button or next to the text if provided.noneno
iconSizestringThe font-size of the icon, any unit is acceptable. e.g: iconSize='2rem' or iconSize='20px'.'initial'no
iconPosition'left', 'right'The position of the icon, relatively to the text if provided.'left'no
shape'pill', 'circle'The shape of the button.regularno
showShadowbooleanDetermines whether the button should have a shadow or not.trueno
showBorderbooleanDetermines whether the button should have a border or not.trueno
borderWidthstringThe width of the border if exists, works with any unit. e.g: borderWidth='2rem' or borderWidth='20px'.'1px'no
borderColorstringBorder color. The name of the color as written in the theme object. e.g borderColor='secDark''bgColor'no
fontWeightstringFont weight of the text. Accepts any valid CSS value.'initial'no

Animation/Hover Props:

propvalueDescriptiondefaultrequired?
hoverColorstringFont color on hover. The name of the color as written in the theme object . e.g hoverColor='sec'colorno
hoverEffect'expand', 'lowerOpacity', '2dClick', 'slideFormLeft', 'slideFromRight'Button animation on hover'expand'.no
slideBgColorstringif a slide hoverEffect was selected, you can specify the background color of the slider. Should be written the same as in the theme object.inverses 'color'&'bgColor'no

Button Element Props:

propvalueDescriptiondefaultrequired?
handleClickfunctionWorks the same as onClick.noneno
disabledbooleanDetermines whether the button should be disabled or not.falseno

Hit me up at david17895@gmail.com if you have any questions.

Also available on LinkedIn

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.0

3 years ago