TypeScript | NativeBase | Universal Components for React and React Native

Nativebase logoNativebase logo
NativeBase
3.4.x
🎉 Prompt to React Native UI
→
Search
⌘
K
Hire us
Light mode active 🚨
Do you really want to stay here? Really? Really? Pakka? Sure? Are you a true developer?
No
Back to DarkMode
Data Display
Typography
Disclosure
Media and Icons
Others
If you are starting a new project, please try gluestack-ui for better performance and new design.
TypeScript
To enable TypeScript for custom theme tokens or variants, we'll follow two simple steps.
Below, in the function, we're adding a space token and a custom variant for the Button.
Copy
import { extendTheme } from 'native-base';
const customTheme = extendTheme({
space: {
'space-2': '29px',
},
components: {
Button: {
variants: {
brand: {
p: '10',
bg: 'brand.500',
},
},
},
},
});
// 2. Get the type of the CustomTheme
type CustomThemeType = typeof customTheme;
// 3. Extend the internal NativeBase Theme
declare module 'native-base' {
interface ICustomTheme extends CustomThemeType {}
}
Result
Nativebase logoNativebase logo
MadeWithNativeBase
Gluestack logoGluestack logo
gluestack-ui
Morty Proxy This is a proxified and sanitized view of the page, visit original site.