title: How to pass a color from one Composable to another?
body: <p>How can I pass a color from one Composable to another? The problem is that the color value in question &quot;cannot be reassigned&quot;, so it seems I can't pass it as a parameter.</p>
  <p>So, basically, this is a snippet from the first Composable:</p>
  <pre><code>val buttonColor = when (index) {
                  0 -&gt; if (isEnabled) Color(0xff81C784)
                  else disabledColor
                  1 -&gt; if (isEnabled) Color(0xff9575CD)
                  else disabledColor
                  2 -&gt; if (isEnabled) Color(0xffFF8A65)
                  else disabledColor
                  3 -&gt; if (isEnabled) Color(0xff5C6BC0)
                  else disabledColor
                  else -&gt; Color.Unspecified
              }
  
              Button(modifier = Modifier.padding(10.dp).height(60.dp),
                  elevation = ButtonConstants.defaultElevation(8.dp),
                  colors = ButtonConstants.defaultButtonColors(
                      backgroundColor = buttonColor
                  ),
              
              
  </code></pre>
  <p>And I want to use that buttonColor as an accent color in the second Composable:</p>
  <pre><code>CustomToggle(color = color,
                      selected = isDisabled.value,
                      onSelected = {
                          isDisabled.value = !isDisabled.value
                          when (index) {
  
                          }
                      }
                  )
              
  </code></pre>
  <p>My idea was simply to bring in the color as a parameter in my parent composable:</p>
  <pre><code>@Composable
      fun MainInterface(context: Context, color: Color) {
      
      [...]
  
  
              bodyContent = {
                  ScrollableColumn(horizontalAlignment = CenterHorizontally) {
                      QuickOptions(context, color)
                      Spacer(modifier = Modifier.height(40.dp))
                      SoundOptions(color)
                  }
  }
  </code></pre>
  <p>But I can't as I can't pass buttonColor as a parameter... I tried to insert the second Composable inside the first one but I still can't pass the color to the second Composable.</p>