{"id":20525776,"url":"https://github.com/andrenerd/react-native-bootstrap-styles","last_synced_at":"2025-08-21T11:33:13.457Z","repository":{"id":54867878,"uuid":"128117963","full_name":"andrenerd/react-native-bootstrap-styles","owner":"andrenerd","description":"Bootstrap style library for React Native ","archived":false,"fork":false,"pushed_at":"2022-02-07T06:28:10.000Z","size":210,"stargazers_count":93,"open_issues_count":0,"forks_count":12,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-12-10T21:41:31.984Z","etag":null,"topics":["android","bootstrap","design","ios","layout","react","react-native","responsive","style","theme"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrenerd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-04T20:27:53.000Z","updated_at":"2024-02-26T10:54:40.000Z","dependencies_parsed_at":"2022-08-14T05:10:42.760Z","dependency_job_id":null,"html_url":"https://github.com/andrenerd/react-native-bootstrap-styles","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrenerd%2Freact-native-bootstrap-styles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrenerd%2Freact-native-bootstrap-styles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrenerd%2Freact-native-bootstrap-styles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrenerd%2Freact-native-bootstrap-styles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrenerd","download_url":"https://codeload.github.com/andrenerd/react-native-bootstrap-styles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230511478,"owners_count":18237657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","bootstrap","design","ios","layout","react","react-native","responsive","style","theme"],"created_at":"2024-11-15T23:09:29.076Z","updated_at":"2024-12-19T23:13:46.076Z","avatar_url":"https://github.com/andrenerd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp\u003e  \n\u003cimg title=\"React Native Bootstrap Styles\" alt=\"React Native Bootstrap Styles\" src=\"./assets/logo.svg\" width=\"15%\"\u003e  \n\u003c/p\u003e  \n\n# React Native Bootstrap Styles  \n\n\n[![npm version](https://img.shields.io/npm/v/react-native-bootstrap-styles.svg)](https://www.npmjs.com/package/react-native-bootstrap-styles)\n\nBootstrap style library for React Native.  \n\nOriginal class names are transformed from \"dashed\" to \"camelcase\" format, for example: `text-center` to `textCenter` and `my-sm-4` to 'mySm4'. Also all the constants (variables in terms of Bootstrap) could be accessible in templates. It helps to make custom tweaks preserving styling guidelines, for example: {fontSize: 10 * FONT_SIZE_BASE}.\n\nDocumentation with snippets and live samples: [alpha version](https://expo.io/@andrenerd/react-native-bootstrap-styles).  \n\n\nBasic \"Hello world\" example:  \n```jsx\nimport React, { Component } from 'react';\nimport { View, Text } from 'react-native';\nimport BootstrapStyleSheet from 'react-native-bootstrap-styles';\n\nconst bootstrapStyleSheet = new BootstrapStyleSheet();\nconst { s, c } = bootstrapStyleSheet;\n\nclass Hello extends Component {\n  render() {\n    return (\n      \u003cView style={[s.body]}\u003e\n        \u003cText style={[s.text, s.textPrimary]}\u003eHello world! 🤓🚀🚀🚀\u003c/Text\u003e\n      \u003c/View\u003e\n    );\n  }\n}\n```\n\nAdvanced \"Hello world\" example with custom styles:\n\n```jsx\nimport React, { Component } from 'react';\nimport { View, Text } from 'react-native';\nimport BootstrapStyleSheet from 'react-native-bootstrap-styles';\n\nconst\n  BODY_COLOR = '#000022',\n  TEXT_PRIMARY = '#882288';\n\n// custom constants\nconst constants = {\n  BODY_COLOR, TEXT_PRIMARY,\n};\n\n// custom classes\nconst classes = {\n  title: {\n    color: 'red',\n  }\n};\n\nconst bootstrapStyleSheet = new BootstrapStyleSheet(constants, classes);\nconst { styles: s, constants: c } = bootstrapStyleSheet;\n\nclass Hello extends Component {\n  render() {\n    return (\n      \u003cView style={[s.body]}\u003e\n        \u003cView style={[s.container, s.h100, s.justifyContentCenter]}\u003e\n          \u003cText style={[s.text, s.title]}\u003eHello world!\u003c/Text\u003e\n          \u003cText style={[s.text, s.textPrimary, s.myXs1, s.myMd3]}\u003eHello second world!\u003c/Text\u003e\n          \u003cText style={[s.text, s.py3, {fontSize: 5 * c.REM}]}\u003e🤓🚀🚀🚀\u003c/Text\u003e\n        \u003c/View\u003e\n      \u003c/View\u003e\n    );\n  }\n}\n```\n\n\n\n\n## Constants\n\nBootstrap renamed `constants` to `variables` some time ago.  \nNo renaming here for now. See actual example above.  \n\nCheck the full list of constants in the source code:  \n[./src/constants.js](./src/constants.js)\n\nExtra dynamic parameters available as `constants` or properties of the `bootstrapStyleSheet` object:\n```js\nDIMENSIONS_WIDTH, // ex. 750\nDIMENSIONS_HEIGHT, //  ex. 1334\nDIMENSIONS_MAX, //  ex. 1334\nORIENTATION_PORTRAIT, // ex. true\nORIENTATION_LANDSCAPE, // ex. false\nMODE_LIGHT, // ex. false\nMODE_DARK, // ex. true\nSCREENS, // ['Xs', 'Md']\nSCREEN, // ex. 'Md'\n```\n\n\n\n## Events\n\nStyles, containing \"media queries\", are automatically updated on dimentions, orientaion and mode changes. There is nothing to bother about, except one little thing. Components should be forced to re-render with the updated styles. That's where the events could be helpful:  \n- addDimensionsListener\n- addOrientationListener (portrait/landscape)\n- addModeListener (light/dark)**\n\nHere is an example:\n\n```jsx\nclass App extends Component {\n\n  componentDidMount() {\n    bootstrapStyleSheet.addDimensionsListener(data =\u003e {\n      // params are accessible\n      // const dimensions = data;\n\n      // direct call\n      // this.forceUpdate();\n\n      // or via state change\n      // this.setState({update: me})\n\n      // or via redux state change\n      // dispatch('NAME', {update: me})\n    });\n  }\n\n  render() {\n    // poor pattern, supposed to be passed in state or props\n    const width = bootstrapStyleSheet.DIMENSIONS_WIDTH\n\n    return (\n      \u003cView style={s.container}\u003e\n        \u003cText style={[s.mediaDependentClass]}\u003eScreen width: {width}\u003c/Text\u003e\n      \u003c/View\u003e\n    );\n  }\n}\n\n```\n\n** extra package should be installed: [react-native-appearance](https://github.com/expo/react-native-appearance).\n\n\n\n## Layout\n\nSimplified version of the original layout classes.\nAny ideas how to extend grid classes are welcome.\n\nImpelemented features: `.container-*`, `.gutters-*`, `.no-gutters-*`. `.row-{screen}-{n}`, `.col-{screen}-{n}`.  \nAmong non-impelemented features: `.row-cols-*`, `.offset-*-*`, `.order-*-*`.  \n\n\n\n## Text\n\nAs there is no such things as \"tag-based\" styles, \"inheritance\" and \"nesting\" for styles in React Native. Extra text classes defined, that should be applied to all `Text` tags, for example:\n```\n\u003cText style=\"{[s.text]}\"\u003eText\u003c/Text\u003e\n\u003cText style=\"{[s.text, s.textSmall]}\"\u003eText\u003c/Text\u003e\n\u003cText style=\"{[s.text, s.textMuted]}\"\u003eText\u003c/Text\u003e\n\u003cText style=\"{[s.text, s.textWhite]}\"\u003eText\u003c/Text\u003e\n\u003cText style=\"{[s.text, s.textBlack50]}\"\u003eText\u003c/Text\u003e\n...\n```\n\nText styles for elements already include base `s.text` style instructions and can be used without it:\n```\n\u003cText style=\"{[s.btnText]}\"\u003eButton text\u003c/Text\u003e\n\u003cText style=\"{[s.formText]}\"\u003eForm text\u003c/Text\u003e\n\u003cText style=\"{[s.formLabelText]}\"\u003eForm label text\u003c/Text\u003e\n\u003cText style=\"{[s.navLinkText]}\"\u003eNav link\u003c/Text\u003e\n...\n```\n\n\n\n## Content and Utilities\n\nCheck the related chapter in the Bootstrap [documentation](https://getbootstrap.com/docs/4.5/utilities/) to get the list of all the utilities.\n\nWhat's implemented or near to:  \n- align \n- background \n- borders \n- display \n- flex \n- sizing \n- spacing \n- text  \n\nalso:  \n- tables\n\n\n\n\n## Elements\n\nBootstrap calls them components. The term is changed to not mess with React components.\nCheck the related chapter in the Bootstrap [documentation](https://getbootstrap.com/docs/4.5/components/) to get the list of all the elements (ie components).\n\nWhat's implemented or neat to: \n- buttons \n- cards \n- forms \n- modal \n- pagination \n- progress \n\n\n\n\n### Buttons\n\n\nTouchableHighlight as button:\n```jsx\n\u003cTouchableHighlight onPress={this.onPress} style=[{s.btnTouchable}]\u003e\n  \u003cView style={[s.btn, s.btnPrimary]}\u003e\n    \u003cText style={[s.btnText, s.btnPrimaryText]}\u003eSignup\u003c/Text\u003e\n  \u003c/View\u003e\n\u003c/TouchableHighlight\u003e\n```\n\nLinks as default and outline buttons with some optional tweaks (see `underlayColor`):\n```jsx\n// import { Link } from 'react-router-native';\n\u003cLink to=\"/submit\" component={TouchableHighlight} underlayColor={c.BLACK} style={[s.btnTouchable]}\u003e\n  \u003cView style={[s.btn, s.btnPrimary]}\u003e\n    \u003cText style={[s.btnText, s.btnPrimaryText]}\u003eSubmit\u003c/Text\u003e\n  \u003c/View\u003e\n\u003c/Link\u003e\n\n\u003cLink to=\"/cancel\" component={TouchableHighlight} underlayColor={c.BLACK} style={[s.btnTouchable, s.mt3]}\u003e\n  \u003cView style={[s.btn, s.btnOutlinePrimary]}\u003e\n    \u003cText style={[s.btnText, s.btnOutlinePrimaryText]}\u003eCancel\u003c/Text\u003e\n  \u003c/View\u003e\n\u003c/Link\u003e\n```\n\n\n\n### Card\n\nBasic card:\n```jsx\n\u003cView style={[s.card]}\u003e\n  \u003cView style={[s.cardBody]}\u003e\n    \u003cText style={[s.text]}\u003eHello Card!\u003c/Text\u003e\n  \u003c/View\u003e\n\u003c/View\u003e\n```\n\n\n\n### Modal\n\nBasic modal (temporal approach, till higher level component added to the lib):\n```jsx\n\u003cModal\n  animationType={animationType}\n  transparent={transparent}\n  visible={this.state.modal}\n  onRequestClose={this.hide}\n  onShow={this.onShown}\n  onDismiss={this.onHidden}\n\u003e\n  \u003cView style={[s.modal]}\u003e\n    \u003cView style={[s.modalDialog]}\u003e\n      \u003cView style={[s.modalContent]}\u003e\n        \u003cText style={[s.text]\u003eHello Modal!\u003c/Text\u003e\n      \u003c/View\u003e\n    \u003c/View\u003e\n  \u003c/View\u003e\n\u003c/Modal\u003e\n```\n\n\n\n### Progress bar\n\nBasic progress bar\n```jsx\n\u003cView style={[s.progress]}\u003e\n  \u003cView style={[s.progressBar, {width: `${progress * 100}%`}]} /\u003e\n\u003c/View\u003e\n```\n\n\n\n\n## Misc\n\n\n### Selectors  \n\nAn attempt to mimic CSS selectors for group pseudo-classes, such as `:first-child`, and media queries:\n```jsx\n\u003cView style={[s.flexRow]}\u003e\n  {\n    group.map((item, index) =\u003e (\n      \u003cView key={index} style={[s.selectorFirstChild(index, s.bgLight)]}\u003e\n        \u003cText style={[s.selectorMediaUpMd([s.text, s.textPrimary])\u003eColored for Md+\u003c/Text\u003e\n        \u003cText style={[s.selectorMediaLandscape([s.text, s.textPrimary])\u003eColored for Lanscape\u003c/Text\u003e\n      \u003c/View\u003e\n    ))\n  }\n\u003c/View\u003e\n```\n\nCheck the full list of selectors in the source code:  \n[./src/mixins/selectors.js](./src/mixins/selectors.js)\n\nSome element classes have selector-based extensions, for example `cardHeaderFirstChild`:\n```\nprovide an example...\n```\n\n\n### Custom\n\n- `flex` is an alias for `flex1`, and the same for `flex{screen}`  \n- some styles contain undocumented, but supported by [Yoga](https://yogalayout.com/), instructions, such as `width: '100%'`. React Native uses Yoga as a layout engine.  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrenerd%2Freact-native-bootstrap-styles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrenerd%2Freact-native-bootstrap-styles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrenerd%2Freact-native-bootstrap-styles/lists"}