npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-lite-ui

v1.0.9

Published

Custom UI components for react-native

Downloads

79

Readme

Custom UI Components with Theming

This package provides customizable and themable React Native components including Buttons, Chips, Text, and TextInput. All components are designed to work seamlessly with a theme context to provide a consistent UI experience.

Installation

npm install react-native-lite-ui

Usage

First, wrap your app with the ThemeProvider and provide initial values for the theme:

Setting Up Theme

Wrap your app with the ThemeProvider and provide initial values for colors, font sizes, and fonts. The ThemeProvider supports both light and dark themes as well as a system-based mode.

import React from 'react';
import { ThemeProvider } from 'react-native-lite-ui';

const App = () => {
  const theme = {
    colors: {
      primary: '#6200EE',
      secondary: '#03DAC6',
      backgroundColor: '#FFFFFF',
      buttonColor: '#6200EE',
      textColor: '#000000',
      disabledColor: '#A9A9A9',
    },
    themesColors: {
      light: {
        primary: '#6200EE',
        backgroundColor: '#FFFFFF',
        textColor: '#000',
        buttonColor: '#03DAC6',
        disabledColor: '#A9A9A9',
      },
      dark: {
        primary: '#BB86FC',
        backgroundColor: '#121212',
        textColor: '#FFFFFF',
        buttonColor: '#03DAC6',
        disabledColor: '#444444',
      },
    },
    fontSizes: {
      medium: 16,
      large: 18,
      extraLarge: 24,
      small: 12,
    },
    fonts: {
      regular: 'System-Regular',
      medium: 'System-Medium',
      bold: 'System-Bold',
    },
  };

  return (
    <ThemeProvider initialValues={theme}>
      {/* Your app code */}
    </ThemeProvider>
  );
};

export default App;

Switching Themes

You can switch themes dynamically using the useTheme hook:

import React from 'react';
import { Button, useTheme } from 'react-native-lite-ui';

const ThemeSwitcher = () => {
  const { themeMode, setThemeMode } = useTheme();

  return (
    <Button
      title={`Switch to ${themeMode === 'dark' ? 'Light' : 'Dark'} Mode`}
      onPress={() => setThemeMode(themeMode === 'dark' ? 'light' : 'dark')}
    />
  );
};

Theming Details

The ThemeProvider allows you to define themes for light and dark modes as well as system-based preferences. It also provides additional customization options for font sizes and font families.

Available Properties

  • Colors:

    • primary
    • secondary
    • backgroundColor
    • buttonColor
    • textColor
    • disabledColor
    • primary2, primary3, secondary2, secondary3
    • backgroundColor2, backgroundColor3
  • Font Sizes:

    • medium, large, extraLarge, small, extraSmall
  • Fonts:

    • regular, medium, bold
  • Theme Modes:

    • 'light', 'dark', 'system'

Example

const theme = {
  colors: {
    primary: '#6200EE',
    secondary: '#03DAC6',
    backgroundColor: '#FFFFFF',
    textColor: '#000000',
    disabledColor: '#A9A9A9',
  },
  themesColors: {
    light: {
      primary: '#6200EE',
      backgroundColor: '#FFFFFF',
      textColor: '#000',
    },
    dark: {
      primary: '#BB86FC',
      backgroundColor: '#121212',
      textColor: '#FFFFFF',
    },
  },
  fontSizes: {
    medium: 16,
    large: 18,
    extraLarge: 24,
  },
  fonts: {
    regular: 'System-Regular',
    medium: 'System-Medium',
    bold: 'System-Bold',
  },
};

Button

A button component that supports multiple styles and theming.

Props

| Prop | Type | Description | Default | |------------|---------------------------------------|-----------------------------------------------------|-------------| | title | string | The text displayed on the button. | required | | onPress | () => void | Function to call when the button is pressed. | required | | style | ViewStyle | Custom style for the button. | undefined | | textStyle| TextStyle | Custom style for the text inside the button. | undefined | | type | 'contained' , 'outline' , 'text' | Button style type. | contained | | radius | 'xl' , 'l' , 'm' , 's' | Border radius of the button. | contained |

Example

import { Button } from 'react-native-lite-ui';

<Button title="Click Me" onPress={() => alert('Button pressed')} type="outline" />

Chip

A chip component that supports multiple styles and theming.

Props

| Prop | Type | Description | Default | |------------|---------------------------------------|-----------------------------------------------------|-------------| | title | string | The text displayed on the chip. | required | | style | ViewStyle | Custom style for the chip. | undefined | | textStyle| TextStyle | Custom style for the text inside the chip. | undefined | | type | 'contained' ,'outline' , 'text' | Chip style type. | contained | | radius | 'xl' , 'l' ,'m' , 's' | Border radius of the chip. | xl | | color | string | Custom color for the chip. | theme.colors.primary |

Example

import { Chip } from 'react-native-lite-ui';

<Chip title="Chip" type="outline" />

Text

A customizable text component that supports multiple font styles and colors.

Props

| Prop | Type | Description | Default | |------------|---------------------------------------|-----------------------------------------------------|-------------| | children | React.ReactNode | The text content inside the component. | required | | fontSize | 'medium',"large","extraLarge","extraExtraLarge","small","extraSmall" | Font Size. | medium | | style | TextStyle | Custom style for the text. | undefined | | mode | 'regular' , 'bold' , 'medium' | Font weight/style of the text. | regular | | colored | boolean | Whether to use the primary color from the theme. | false |

Example

import { Text } from 'react-native-lite-ui';

<Text mode="bold" colored={true}>Hello World</Text>

TextInput

A customizable text input field with support for different font weights.

Props

| Prop | Type | Description | Default | |------------|---------------------------------------|-----------------------------------------------------|-------------| | style | TextStyle | Custom style for the text input. | undefined | | fontWeight| 'regular' , 'bold' , 'medium' | Font weight of the text input. | regular |

Example

import { TextInput } from 'react-native-lite-ui';

<TextInput placeholder="Type here" fontWeight="bold" />

Theming

All components use the useTheme hook to apply colors, fonts, and styles from a theme. To change the appearance globally, provide custom values via the ThemeProvider.

import { ThemeProvider } from 'react-native-lite-ui';

const theme = {
  colors: {
    primary: '#6200EE',
    textColor: '#000',
  },
   fontSizes:{
      medium: 14,
      large: 16,
      extraLarge: 18,
      extraExtraLarge: 50,
      small:12,
      extraSmall: 10
  },
  fonts: {
    regular: 'System-Regular',
    medium: 'System-Medium',
    bold: 'System-Bold',
  },
};

<ThemeProvider initialValues={theme}>
  {/* Your app code */}
</ThemeProvider>

License

This project is licensed under the MIT License.

react-native-lite-ui