{"id":10923,"date":"2024-07-18T05:43:37","date_gmt":"2024-07-18T05:43:37","guid":{"rendered":"https:\/\/www.bacancytechnology.com\/qanda\/?p=10923"},"modified":"2024-07-18T05:44:06","modified_gmt":"2024-07-18T05:44:06","slug":"set-width-in-react-native-style","status":"publish","type":"post","link":"https:\/\/www.bacancytechnology.com\/qanda\/react-native\/set-width-in-react-native-style","title":{"rendered":"React Native Styling Width: Percentage &#8211; Number"},"content":{"rendered":"<p>You can modify your styles to depend on React Native&#8217;s flex attributes to develop a layout where the AutoComplete component covers the remaining space and the icon has a fixed width. Here&#8217;s how to go about it:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\">import React from 'react';\r\nimport { StyleSheet, View } from 'react-native';\r\n\r\nconst App = () =&gt; {\r\n  return (\r\n    &lt;View style={styles.container}&gt;\r\n      &lt;View style={styles.row}&gt;\r\n        &lt;View style={styles.subContainer}&gt;\r\n          {\/* AutoComplete component goes here *\/}\r\n        &lt;\/View&gt;\r\n        &lt;View style={styles.icon}&gt;\r\n          {\/* Icon goes here *\/}\r\n        &lt;\/View&gt;\r\n      &lt;\/View&gt;\r\n    &lt;\/View&gt;\r\n  );\r\n};\r\nconst styles = StyleSheet.create({\r\n  container: {\r\n    flex: 1,\r\n    paddingTop: 100,\r\n  },\r\n  row: {\r\n    flexDirection: 'row',\r\n    height: 50,\r\n  },\r\n  subContainer: {\r\n    flex: 1,\r\n    backgroundColor: 'dodgerblue',\r\n  },\r\n  icon: {\r\n    width: 50,\r\n    backgroundColor: 'greenyellow',\r\n  },\r\n});\r\nexport default App;\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can modify your styles to depend on React Native&#8217;s flex attributes to develop a layout where the AutoComplete component covers the remaining space and the icon has a fixed width. Here&#8217;s how to go about it: import React from &#8216;react&#8217;; import { StyleSheet, View } from &#8216;react-native&#8217;; const App = () =&gt; { return [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":10925,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-10923","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-react-native"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/10923"}],"collection":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/comments?post=10923"}],"version-history":[{"count":2,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/10923\/revisions"}],"predecessor-version":[{"id":10928,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/10923\/revisions\/10928"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media\/10925"}],"wp:attachment":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media?parent=10923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/categories?post=10923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/tags?post=10923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}