Skip to content

Responsive styling #49

@davidgovea

Description

@davidgovea

The responsive styling experience of tailwindcss is great. Mobile-first, then sm:, md:, lg:, xl: prefixes for breakpoints.

When thinking about the function-helpers in for lineHeight in issue #48, I thought that maybe this could work for responsive helpers, too.

Imagine:

import { t, md, xl } from 'react-native-tailwindcss';

<View style={[t.w16, md(t.w24), xl(t.w32)]} />

Internally, the helpers would look something like:

const md = (styles) => Dimensions.get('window').width > 1000 ? styles : undefined

The question is -- would this "screen-width breakpoints" approach be helpful in react-native?
I've been watching some approaches to responsive styling, and I'm not quite sure yet.


So, any thoughts?
It could be reasonable to omit all of this from rn-tailwind, and rely on other utilities for this functionality.
On the other hand, this is a pretty central feature to tailwind (IMO).

After reviewing the above repos, I think there could be a place for tailwinds "increasing-breakpoints" approach (min-width queries only, no max-width or ranges). "Scaling" approaches should probably stay in their own utilities.. could always do scaleSizeUtilityFromOtherLibrary(t.w16.width) or similar

The things I still want to brainstorm on are PixelRatio and orientation -- these exist on web too, but perhaps they're more critical in nativeland? Should the sm, md, etc breakpoints be based on screen width, or minimum-edge length?

If you've gotten this far, thanks a lot for reading!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions