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 🙏

© 2026 – Pkg Stats / Ryan Hefner

prestyles

v1.0.6

Published

React Native StyleSheet alternative that supports platform switching and functional styles

Downloads

29

Readme

Prestyles

A simple little package that makes writing cross-platform responsive RN styles a bit tidier.

Installation

yarn add prestyles

Usage (createStyles)

  1. Import the library

    import createStyles from 'prestyles';

  2. Use this function where you would normally use StyleSheet.create();

  3. This library allows you to add sub objects to your style objects that contain platform specific styles.

    const styles = createStyles({
       button: {
           backgroundColor: 'red',
           web: {
               backgroundColor: 'blue'
           }   
       }
    });

    Consume your styles as normal:

    <Button style={styles.button}/>

    The supported platform keys are:

    • web (only used on web)
    • native (used on ios and android)
    • ios (used on ios)
    • android (used on android)
  4. This library also allows you to pass params to your style objects

    const styles = createStyles({
       button: (color) => ({
           fontSize: 12,
           color: color,
           native: {
               fontSize: 10
           }
       })
    });

    Consume:

    <Button style={styles.button('red')}/>

Usage (responsiveStyles)

  1. Configure your breakpoints at top level App.js or wherever. (If you skip this step these are the default breakpoints)

    import {setBreakpoints} from 'prestyles';
       
    setBreakpoints({
        desktop: 1024, // min width,
        tablet: 768, // min width
        mobile: 0
    });
  2. Import the style creator and hook

    import createStyles, {
       useResponsiveStyles
    } from 'prestyles';
  3. Create styles with breakpoint sub styles

    const styles = createStyles({
       container: {
           backgroundColor: 'white', // Will be shown if no matching breakpoint
           desktop: {
               backgroundColor: 'blue' // Will be show on > 1024 widths
           },
           tablet: {
               backgroundColor: 'red'
           },
           mobile: {
               backgroundColor: 'green'
           }   
       }
    });
  4. Use the useResponsiveStyles hook to consume styles that will dynamically change based on matching breakpoints

    const Foo = () => {
       const [responsiveStyles] = useResponsiveStyles(styles);
      
       return (
           <View style={responsiveStyles.container}/>
       )  
    }
  5. The useResponsiveStyles hook accepts three params.

    1. The required styles object generated from createStyles
    2. A boolean to enable/disable the styles to spill over (upwards). Read section about this.
    3. An optional custom breakpoint object that will overwrite whatever was set at top-level with setBreakpoints
  6. The useResponsiveStyles hook returns an array with 3 values:

    1. The parsed styles
    2. A boolean letting you know if the styles are ready (in cased you experience any flicker between the default styles, and the matched styles on load).
    3. An updated screen with value if you need it for anything
  7. All breakpoints will be compared with >= (larger than or equal), this means styles will overflow upwards. IE tablet will inherit mobile styles, and desktop will inherit tablet styles. You can prevent this by either passing false as the second to the useResponsiveStyles hook, or by declaring your styles as exact match only by prefixing them with an underscore. _mobile will only render on mobile, _tablet only on desktop. You can also prefix your custom breakpoints the same way.