SDK Props Reference
VoteNowButton Props
| Prop | Type | Required | Description |
|---|---|---|---|
| URL | string | Required | The voting URL obtained from the VOTR API. |
| label | string | Optional | Button text. Defaults to "Vote Now". |
| buttonStyle | ViewStyle | Optional | Custom styling for the button container. |
| textStyle | TextStyle | Optional | Custom styling for the button label text. |
| isDisabled | boolean | Optional | Whether the button is disabled. |
| onPress | () => void | Optional | Called when the button is pressed. |
| onSuccess | () => void | Optional | Called when voting completes successfully. |
| onError | (error: string) => void | Optional | Called when an error occurs during the voting flow. |
| onBack | () => void | Optional | Called when the user closes the voting modal. |
Example with All Props
VoteButton.tsx — every prop wired up
<VoteNowButton
URL={votingUrl}
label="Submit Your Vote"
buttonStyle={{
backgroundColor: "#28a745",
borderRadius: 12,
paddingVertical: 16,
paddingHorizontal: 32,
elevation: 3,
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
}}
textStyle={{
color: "#ffffff",
fontSize: 18,
fontWeight: "600",
textAlign: "center",
}}
isDisabled={!votingUrl}
onPress={() => console.log("Vote button pressed")}
onSuccess={() => {
Alert.alert("Success", "Vote submitted successfully!");
navigation.goBack();
}}
onError={(error) => {
console.error("Voting error:", error);
Alert.alert("Error", "Failed to submit vote. Please try again.");
}}
onBack={() => {
console.log("User cancelled voting");
}}
/>
Advanced Usage with Custom Styling
VoteButton.tsx — branded button with custom shadow
<VoteNowButton
URL={votingUrl}
label="Cast Your Vote"
buttonStyle={{
backgroundColor: "#007AFF",
borderRadius: 8,
paddingVertical: 12,
paddingHorizontal: 24,
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
}}
textStyle={{
color: "white",
fontSize: 16,
fontWeight: "bold",
}}
onSuccess={() => {
Alert.alert("Success", "Your vote has been recorded!");
}}
onError={(error) => {
Alert.alert("Error", `Voting failed: ${error}`);
}}
/>