question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to change the background of List.Accordion

See original GitHub issue

This is my code:

<List.Section title="Accordions" style={{ backgroundColor: 'white' }}>
      <List.Accordion
       style={{ backgroundColor: 'white', marginBottom: 20 }}
        title="Uncontrolled Accordion"
        left={props => <List.Icon {...props} icon="folder" />}>
        <List.Item title="First item" />
        <List.Item title="Second item" />
      </List.Accordion>

      <List.Accordion
      style={{ backgroundColor: 'white', marginBottom: 20 }}
        title="Controlled Accordion"
        left={props => <List.Icon {...props} icon="folder" />}
        expanded={expanded}
        onPress={handlePress}>
        <List.Item title="First item" />
        <List.Item title="Second item" />
      </List.Accordion>
    </List.Section>

https://snack.expo.dev/@allwithyou999/14e46c?name=List.Accordion&description=https%3A%2F%2Fcallstack.github.io%2Freact-native-paper%2Flist-accordion.html&code=import * as React from ‘react’%3B import { List } from ‘react-native-paper’%3B const MyComponent %3D () %3D> { const [expanded%2C setExpanded] %3D React.useState(true)%3B const handlePress %3D () %3D> setExpanded(!expanded)%3B return ( <List.Section title%3D"Accordions"> <List.Accordion title%3D"Uncontrolled Accordion" left%3D{props %3D> <List.Icon {...props} icon%3D"folder" %2F>}> <List.Item title%3D"First item" %2F> <List.Item title%3D"Second item" %2F> <%2FList.Accordion> <List.Accordion title%3D"Controlled Accordion" left%3D{props %3D> <List.Icon {...props} icon%3D"folder" %2F>} expanded%3D{expanded} onPress%3D{handlePress}> <List.Item title%3D"First item" %2F> <List.Item title%3D"Second item" %2F> <%2FList.Accordion> <%2FList.Section> )%3B }%3B export default MyComponent%3B&dependencies=react-native-paper But I can’t change the gray color of the screen: Screen Shot 2021-12-03 at 10 47 48 AM

Please help me.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

15reactions
lukewalczakcommented, Dec 5, 2021

You can achieve it by passing a theme prop into List.Accordion with customized background color, in the following way:

<List.Accordion
    theme={{colors: {background: 'orange'}}}
    style={{ backgroundColor: 'white', marginBottom: 20 }}
    title="Uncontrolled Accordion"
    left={(props) => <List.Icon {...props} icon="folder" />}>
        <List.Item title="First item" />
        <List.Item title="Second item" />
</List.Accordion>
0reactions
shizuo-xcommented, Aug 15, 2022

I advice to use a spacer to space the lists, for OP and not to use the margin because it will push down the drop down options too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react native paper list accordion - Stack Overflow
I am having a problem with react-native paper list accordion it is not working on android! I mean the list is showing but...
Read more >
List.Accordion · React Native Paper
A component used to display an expandable list item.
Read more >
Accordion · Bootstrap v5.0
This is the first item's accordion body. It is shown by default, until the collapse plugin adds the appropriate classes that we use...
Read more >
List.Accordion - Expo Snack
https://callstack.github.io/react-native-paper/list-accordion.html.
Read more >
[Share] Accordion Block: Useful code - Squarespace Forum
tuanphan · #1. Change Dividers Color · #2. Change Arrows Color · #3. Add icons before Accordion Titles · #4. Different Color for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found